Image of Category as background Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

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.
3 posters

    Image of Category as background

    SarkZKalie
    SarkZKalie
    Support Moderator
    Support Moderator


    Male Posts : 1443
    Reputation : 220
    Language : English

    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)
    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, 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.
    SarkZKalie
    SarkZKalie
    Support Moderator
    Support Moderator


    Male Posts : 1443
    Reputation : 220
    Language : English

    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!
    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, 8:02 pm

    Solved => Archived