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.
The forum of the forums
3 posters

    Image of Category as background

    SarkZKalie
    SarkZKalie
    Support Moderator
    Support Moderator


    Male Posts : 1442
    Reputation : 220
    Language : English

    Solved Image of Category as background

    Post by SarkZKalie November 14th 2014, 10: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, 5:39 pm; edited 1 time in total (Reason for editing : Topic Solved)
    Ange Tuteur
    Ange Tuteur
    Forumaster


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

    Solved Re: Image of Category as background

    Post by Ange Tuteur November 14th 2014, 10: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.
    SarkZKalie
    SarkZKalie
    Support Moderator
    Support Moderator


    Male Posts : 1442
    Reputation : 220
    Language : English

    Solved Re: Image of Category as background

    Post by SarkZKalie November 14th 2014, 5: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!
    Base
    Base
    Forumaster


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

    Solved Re: Image of Category as background

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

    Solved => Archived

      Current date/time is September 22nd 2024, 5:32 pm