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

How do I use a conditional for a specific node in a template?

Discussion in 'XenForo Development Discussions' started by Brogan, Dec 6, 2010.

  1. Brogan

    Brogan XenForo Moderator Staff Member

    I want to try and remove the breadcrumbs from a specific page.

    So I started off by editing the PAGE_CONTAINER template like so:
    PHP:
    <xen:if is="{$node.node_id} !={$page.node_id}">
    <
    div class="breadBoxTop">
    <
    xen:if is="{$topctrl}"><div class="topCtrl">{xen:raw $topctrl}</div></xen:if>
    <
    xen:include template="breadcrumb"><xen:set var="$microdata">1</xen:set></xen:include>
    </
    div>
    </
    xen:if>
    The if statement is my addition to try and remove the breadcrumbs for any node which is a page but it doesn't work.
    It actually removes the (top) breadcrumb from every page view.

    Ultimately I want to be able to change the xen:if to use a specific node id (55) so I can use a Page as the home page without the breadcrumbs top and bottom.

    Help appreciated :D
     
    Digital Doctor likes this.
  2. Floris

    Floris Guest

    Make it a step simpler? If page.node_id is not set, show breadcrumb.
     
  3. Brogan

    Brogan XenForo Moderator Staff Member

    Yeah I tried that too, it does nothing o_O
     
  4. Floris

    Floris Guest

    in PAGE_CONTAINER the $page.node_id is always empty it seems.
     
  5. Kier

    Kier XenForo Developer Staff Member

    == ! means something very different from !=
     
  6. Brogan

    Brogan XenForo Moderator Staff Member

    Go easy on us learners :D

    I tried using <xen:if is="{$node.node_id} != {$page.node_id}"> and that removes the breadcrumbs from every node.

    Similarly if I use <xen:if is="{$node.node_id} == {$page.node_id}"> then the breadcrumbs are visible on every node.

    I can't seem to remove them just for page nodes.
     
  7. Indigo

    Indigo Active Member

    Try checking if {$node.node_type_id} == 'Page'. node_type_id can be either Page, Forum, LinkForum, or Category (possibly more if you have an addon that defines more).
     
  8. Jaxel

    Jaxel Well-Known Member

    Why dont you just use:

    Code:
    <xen:if is="{$node.node_type_id} != 'Page'">
    edit: looks like Indigo already answered it... oops
     
  9. Brogan

    Brogan XenForo Moderator Staff Member

    Thanks guys, unfortunately that also doesn't work.
     
  10. Indigo

    Indigo Active Member

    It sounds like you wanted to hide the breadcrumbs from a page node with ID = 55? Technically you shouldn't even need to check the type.
    Code:
    <xen:if is="{$node.node_id} != 55">
    <!-- breadcrumbs -->
    </xen:if>
    Unless $node is not defined in that context.
     
  11. Brogan

    Brogan XenForo Moderator Staff Member

    Still no go :(
     
  12. Itworx4me

    Itworx4me Well-Known Member

    Should it be:

    Code:
    <xen:if is="{$node.node_id} != '55'">
    <!-- breadcrumbs -->
    </xen:if>
    
     
  13. Brogan

    Brogan XenForo Moderator Staff Member

    Still not working :D

    I should turn this into a competition to see who can work it out first.
    I have a feeling though it's not possible in this particular template.
     
  14. Itworx4me

    Itworx4me Well-Known Member

    Why not try your code in the pagenode_container template?
     
  15. Brogan

    Brogan XenForo Moderator Staff Member

    I've tried it there also, without success.

    Oh well, I'll put it on the back-burner for now.

    I just thought it would have been nice to show pages without the breadcrumbs so they looked less like part of the forum and more like an html page with the same header and footer.
     
  16. Indigo

    Indigo Active Member

    http://www.anfinitinetwork.com/xftest/pages/testing/

    Did it with:
    Code:
    <xen:if is="{$quickNavSelected} != 'node-3'">
    	<div class="breadBoxTop">
    	<xen:if is="{$topctrl}"><div class="topCtrl">{xen:raw $topctrl}</div></xen:if>
    	<xen:include template="breadcrumb"><xen:set var="$microdata">1</xen:set></xen:include>
    	</div>
    </xen:if>
    Replace "node-3" with "node-55" or any number you want. Repeat for bottom breadcrumbs if necessary. This was in beta 3 (haven't gotten around to upgrading), so hopefully quickNavSelected hasn't changed since then.
     
    arabic, Brogan and Digital Doctor like this.
  17. Digital Doctor

    Digital Doctor Well-Known Member

  18. Brogan

    Brogan XenForo Moderator Staff Member

    Digital Doctor likes this.
  19. Digital Doctor

    Digital Doctor Well-Known Member

    Does this still work xenforo RC1 ?
     

Share This Page