The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Image of Category as background

Go down

Solved Image of Category as background

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

Hello

I have a forum category like this image below, and i call it F1 :


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 http://i.imgur.com/k6hwhcd.jpg - not http://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:

ID username: Calypso
PW: qaz!@#456

Tks for reading!


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

Male Posts : 644
Reputation : 93
Language : English

http://rotavn.nstars.org/

Back to top Go down

Solved Re: Image of Category as background

Post by Ange Tuteur on 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.
avatar
Ange Tuteur
Forumaster

Male Posts : 13187
Reputation : 2895
Language : EN10, FR5
Location : Macungie, PA

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Image of Category as background

Post by SarkZKalie on 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!

Thanks again, Katty!
avatar
SarkZKalie
Forumember

Male Posts : 644
Reputation : 93
Language : English

http://rotavn.nstars.org/

Back to top Go down

Solved Re: Image of Category as background

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

Solved => Archived
avatar
Base
Forumaster

Male Posts : 10386
Reputation : 1693
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