1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.5 Detect if Forum/Home Page is selected?

Discussion in 'Styling and Customization Questions' started by Sidradi, Feb 4, 2016.

  1. Sidradi

    Sidradi Member

    Hi guys,

    I'm trying to do something only if it's forum page !! (some CSS)
    i'm using this code but it's not working !!

    <xen:if is="{$contentTemplate} == 'forum_list'">
    <xen:else />
    I also tried using : " <xen:if is="{$tabs.forums.selected}"> " instead but it's not working !!

    Can you please tell me how to do it ??

    NB : I tried these based on the answears here : https://xenforo.com/community/threads/how-to-detect-if-the-home-page-is-selected.45208/
  2. Brogan

    Brogan XenForo Moderator Staff Member

    You can't use conditional statements in CSS templates.

    You would have to edit the template and add the class or CSS that way, or style the element using a specific selector.

    If you can explain what you are trying to change, it may be possible using EXTRA.css.
  3. Sidradi

    Sidradi Member

    I even tried to do it in the template node_forum_level_2 but still it's like this conditions is wrong !
    is there a way to check the page ?? for exemple if we are in the main page ?
  4. Brogan

    Brogan XenForo Moderator Staff Member

    Yes, using that conditional statement.

    It won't necessarily work in an included template though.
  5. Sidradi

    Sidradi Member

    So what is the correct conditional statement to use ?
  6. Russ

    Russ Well-Known Member

    What exactly are you trying to achieve? All of the content (not the header/footer) is wrapped in a div which has a unique class. The forum_list for instance:

    <div id="content" class="forum_list">
    So you can use CSS to target things specific to that page, .forum_list .sidebar h3 { blah blah}
    Sidradi likes this.
  7. Daniel Hood

    Daniel Hood Well-Known Member

    You can see if template variables are included (and what the value is) in a template by doing {xen:helper dump, $var}. Though, there may be a better solution like @Russ said if you tell us what you're shooting for.
  8. Sidradi

    Sidradi Member

    Thanks Bro ;) works as charm !
    Daniel Hood and Russ like this.

Share This Page