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

Conditional tags

Discussion in 'Styling and Customization Questions' started by A.Chakery, Jul 8, 2012.

  1. A.Chakery

    A.Chakery Active Member

    Hello,

    I need some conditional tags as below :

    1- <If This is a Thread> SHOW THIS CODE</if>
    2-<If This is a Forum> SHOW THIS CODE</if>

    Any help is appreciated ...


    thank you
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    Code:
    <xen:if is="{$controllerName} == 'XenForo_ControllerPublic_Thread'">
    Code to show in thread
    </xen:if>
    Code:
    <xen:if is="{$controllerName} == 'XenForo_ControllerPublic_Forum'">
    Code to show in forum
    </xen:if>
    Should do it ;)
     
    A.Chakery likes this.
  3. A.Chakery

    A.Chakery Active Member

    Thank you very much .. but they didn't work ..

    Actually I need them to use H1 codes in it like below :

    Code:
                                    <xen:if is="{$controllerName} == 'XenForo_ControllerPublic_Thread'">
                                    <h1 class="itemLabel">{xen:helper threadPrefix, $thread}{$thread.title}</h1>
                                    </xen:if>
                                    <xen:if is="{$controllerName} == 'XenForo_ControllerPublic_Forum'">
                                    <h1 class="itemLabel">{$forum.title}</h1>
                                    </xen:if>
                                    <xen:if is="{$controllerName} == 'XenForo_ControllerPublic_Page'">
                                    <h1 class="itemLabel">{$page.title}</h1>
                                    </xen:if>
    do you have any idea how to do it ?


    thank you
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    What template are you using the conditions in? Are you editing the PAGE_CONTAINER?

    You probably need to use xen:container as the node / thread records aren't always made available to the container. For example:

    Admin CP -> Appearance -> Templates -> forum_view

    Add this line to the top of the template:

    Code:
    <xen:container var="$h1Title">{$forum.title}</xen:container>
    
    Admin CP -> Appearance -> Templates -> thread_view

    Add this line to the top of the template:

    Code:
    <xen:container var="$h1Title">{$thread.title}</xen:container>
    
    That will pass the forum or thread title to the container as $h1Title such that you can use code like this in PAGE_CONTAINER:

    Code:
    <xen:if is="{$h1Title}">
    <h1 class="itemLabel">{$h1Title}</h1>
    </xen:if>
    
    But having said that, there is already h1 code in the PAGE_CONTAINER, and values are already passed to it from the content templates (e.g. forum_view and thread_view) using a special xen:h1 tag:

    Code:
    <xen:h1>{$forum.title}</xen:h1>
    
    So what you are trying to do might be redundant.
     
  5. A.Chakery

    A.Chakery Active Member

    Thank you for the reply ... no I am trying to put it in the header ...

    and then I wanna change the current H1 codes to H2 ....
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    The header is in the container scope, so the xen:container stuff still applies.
     
  7. A.Chakery

    A.Chakery Active Member

    actually I am editing the header_bar template


    (its located at the top of the screen)...

    so how should I edit it ?

    Thank you
     
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    If that template is included by PAGE_CONTAINER or header then it is still in the container scope. Anything to do with the header is probably in the container scope, so the xen:container stuff still applies.
     
  9. A.Chakery

    A.Chakery Active Member

    thank you .. it worked ...

    And would you please tell me how can I do this for pages ?
     
  10. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    You would use xen:container in this template to affect all page nodes:

    Admin CP -> Appearance -> Templates -> pagenode_container
     
  11. A.Chakery

    A.Chakery Active Member

    thank you very much .. it worked great ...

    Another question : (sorry if I am asking too much :) )

    Would you please tell me how can I change the default XF H1 tags into H2 ?

    thanks
     
  12. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Admin CP -> Appearance -> Templates -> PAGE_CONTAINER

    Search for "h1".
     
  13. A.Chakery

    A.Chakery Active Member

    Thanks very much for all the help ...
     

Share This Page