How to set a differnt background for each page

Discussion in 'Joomla' started by Webed4it, Sep 24, 2010.

  1. #1
    How would I go about setig a different background image for each page. Is there a way to set the class of the container div depending on the URL or is there a better way than that?
     
    Webed4it, Sep 24, 2010 IP
  2. AdvancedNoob

    AdvancedNoob Guest

    Messages:
    101
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    No, some template have such options. One I remember is Sea Glass by Shape5.
     
    AdvancedNoob, Sep 26, 2010 IP
  3. davidtran

    davidtran Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes, there are many way to do this. You can use the following sample:
    $option = JRequest::getVar('option'); // this is to help you to find the component on current view
    $taskmode = JRequest::getCmd('task'); // this is to find the current task
    if($option == "com_content"){ // if viewing com_content, set div style
        if($taskmode=="edit"){ // if current task is "edit", set div style "style1"
            $div = "style1";
        }// otherwise set div style "style2"
        $div = "style2";
    }elseif($option == "com_abc"){ // if viewing com_abc, set div "style3"
        $div = "style3";
    }
    
    PHP:
    And many more.
    Add the above to your template file then you are done.
    Please check Joomla Docs to see details.
     
    davidtran, Sep 28, 2010 IP
  4. JohnnyRocket

    JohnnyRocket Member

    Messages:
    126
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #4
    every page can me customized. the code above is the way i would do it too.
     
    JohnnyRocket, Sep 30, 2010 IP
  5. davidtran

    davidtran Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yes, you can customize each and every page with the above procedure if you can get the id of the page.
     
    davidtran, Sep 30, 2010 IP
  6. SovietZoo

    SovietZoo Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Whenever i wanted to that I just assigned a different ID to every page with javascript and passed that back a corresponding CSS file. That's prolly the longest way in the world to do it though, look for faster solutions
     
    SovietZoo, Oct 1, 2010 IP
  7. davidtran

    davidtran Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    If a browser does not support javascript, your work becomes reduntdant.
     
    davidtran, Oct 1, 2010 IP
  8. JohnnyRocket

    JohnnyRocket Member

    Messages:
    126
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #8
    The browser does need javascript. I have had this problem.
     
    JohnnyRocket, Oct 4, 2010 IP
  9. Chocolate Lime

    Chocolate Lime Active Member

    Messages:
    399
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #9
    Templates can be assigned to menu items - why not do that?
     
    Chocolate Lime, Oct 6, 2010 IP
  10. davidtran

    davidtran Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    You can do this some cases and you cannot in some others.
    For example, I have a menu linked to a content category. Yes, I can assign a template to this menu and all the articles belonging to that category will be affected by the assigned template.
    But, when I want some of those articles have different style, how can I do if I don't use "JRequest::getVar"?
     
    davidtran, Oct 6, 2010 IP
  11. palq4o

    palq4o Guest

    Messages:
    28
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #11
    davidtran - then you have to create a new menu and to add you pages in it - you dont need to create a module for this menu or to show it somewhere. After you create all the things above you can assign different template to every single page of this menu. Yes i know that this is a lot of work but in some cases this is the only thing you can do.
     
    palq4o, Oct 12, 2010 IP
  12. davidtran

    davidtran Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    With my way of "JRequest::getVar", you don't need to create any menu for it because the input used can be an article id (for Joomla article content) or something similar like Sobi 2 entry id. My way is menu-independent!

    If you want it to be menu-dependent, you still can use my way with var of Itemid, e.g. JRequest::getVar('Itemid') where Itemid was assigned to a menu when you had created that menu.
     
    Last edited: Oct 12, 2010
    davidtran, Oct 12, 2010 IP