The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Image of Category as background

3 posters

Go down

Solved Image of Category as background

Post by SarkZKalie November 14th 2014, 8:31 am

Hello

I have a forum category like this image below, and i call it F1 :
Image of Category as background Catego10

I wanna change background of the entire topics in that forum category. Exp: when my users are redirecting to a post belong to F1 category, then body background will be change to https://i.imgur.com/k6hwhcd.jpg - not https://i.imgur.com/LBzrHIc.jpg .And of cuz, it should work on forum categorys, but another image

Code:
Default background - work all the page
body{background:url('http://i.imgur.com/LBzrHIc.jpg')}

Work only on F1 category
body{background:url('http://i.imgur.com/k6hwhcd.jpg') no-repeat !important)

Work only on F2 category
body{background:url('http://i.imgur.com/ELh2eeA.jpg') no-repeat !important)
And 1 more, they're never show on Index homepage, just work on special categorys that I've applied for. Is this possible?

My forum: http://rotavn.nstars.org/
Test account:

Tks for reading!


Last edited by sarkzkalie01 on November 14th 2014, 3:39 pm; edited 1 time in total (Reason for editing : Topic Solved)
SarkZKalie
SarkZKalie
Support Moderator
Support Moderator

Male Posts : 1407
Reputation : 218
Language : English

https://rotavn.forumotion.com/

Back to top Go down

Solved Re: Image of Category as background

Post by Ange Tuteur November 14th 2014, 8:51 am

Hello sarkzkalie01,

The most I can think of is using regular expressions to check the window location for when you're in the category, and the navlinks for when you're in a topic. If any of those are true we'll change the background image.

Give this a try :
Administration Panel > Modules > JavaScript codes management > Create a new script

Title : Your choice
Placement : In all the pages
Code:
$(function() {
  changeBg(/\/f1-/, 'http://i.imgur.com/k6hwhcd.jpg');
  changeBg(/\/f2-/, 'http://i.imgur.com/ELh2eeA.jpg');

  function changeBg(fid, img) {
    var a = document.getElementsByTagName('A'),i;
    if (fid.test(window.location.pathname)) setBg();
    else for (i=0; i<a.length; i++) if (fid.test(a[i].href) && /nav/.test(a[i].className)) setBg();
    function setBg() { document.body.style.backgroundImage = 'url('+img+')' };
  };
});

If you need an explanation of the function arguments let me know.
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Image of Category as background

Post by SarkZKalie November 14th 2014, 3:38 pm

Hey, I just edited f1 to f5 and it worked. That's really what I want

You're so amazing!
Image of Category as background ?sticker_id=229801647168451&image_type=BestEffortImage
Thanks again, Katty!
SarkZKalie
SarkZKalie
Support Moderator
Support Moderator

Male Posts : 1407
Reputation : 218
Language : English

https://rotavn.forumotion.com/

Back to top Go down

Solved Re: Image of Category as background

Post by Base November 14th 2014, 8:02 pm

Solved => Archived
Base
Base
Forumaster

Male Posts : 10386
Reputation : 1695
Language : English and French
Location : United Kingdom, England

http://forumotionhub.net

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum