1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Building Breadcrumb (via Templates)

Discussion in 'Development Tutorials [Archive]' started by Jeremy, Oct 7, 2010.

  1. Jeremy

    Jeremy XenForo Moderator Staff Member

    So, unlike vBulletin breadcrumbs are built inside of templates (and as Kier so aptly pointed out, my example below is directly from him. :D)

    XenForo comes with this handy, dandy little tag called:
    HTML:
    <xen:navigation></xen:navigation>
    Inside of it, you place the following code to build your navigation (and I'm assuming the more you have, the deeper the level, but don't quote me on that):
    HTML:
    	<xen:breadcrumb href="Linky">Title</xen:breadcrumb>
    However, Jaxel has figured out how to do this programmatically. Instead of placing an href="" inside of the title, place the following HTML in the template:
    HTML:
    <xen:breadcrumb source="$breadCrumbs"></xen:breadcrumb>
    And the following in your class:
    PHP:
    $breadCrumbs['test'] = array(
        
    'value' => 'test',
         
    'href' => XenForo_Link::buildPublicLink('full:portal'$page)   );
    So, you're final "navigation/breadcrumb" setup (where as vBulletin you required PHP code and such to build this) would look as such:
    HTML:
    <xen:navigation>
    <xen:breadcrumb href="Linky">Title</xen:breadcrumb>
    </xen:navigation>
    
    So, this is probably the first actual thing I've learned about XenForo's inner structure, and I'm proud of it... So, thank you Kier (even tho you sorta made fun of me. :p)!
     
    AndyB and CurveGotti like this.
  2. Kier

    Kier XenForo Developer Staff Member

    Of course, we make use of the non-programatic version all over the place. Right now, only stuff in the node tree builds its breadcrumbs automatically. For most pages, we build the breadcrumb right in the template, for example:

    HTML:
    <xen:navigation>
    	<xen:breadcrumb href="{xen:link full:conversations}">{xen:phrase conversations}</xen:breadcrumb>
    	<xen:breadcrumb href="{xen:link full:conversations, $conversation}">{$conversation.title}</xen:breadcrumb>
    </xen:navigation>
     
    CNK and CurveGotti like this.
  3. Kier

    Kier XenForo Developer Staff Member

    Oooh, I should point out that in order to satisfy the breadcrumb microdata, you should use the 'full' form of the link builder, and you should always call XenForo_Link, rather than trying to fetch the route prefix class.

    So, not this:
    PHP:
    'href' => $this->getModelFromCache('YourAddon_Route_Prefix_Portal')->buildLink('portal'''''$page),
    and not this
    PHP:
    'href' => XenForo_Link::buildPublicLink('portal'$page),
    but this
    PHP:
    'href' => XenForo_Link::buildPublicLink('full:portal'$page),
     
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

    Updated. Thanks Kier. ;)
     
  5. ragtek

    ragtek Guest

    I can't see any difference using the buildPublicLink with full and without full.

    For what is this?

    this is my code:

    <xen:breadcrumb href="{xen:link 'full:articlecategory', $category}">{$category.title}</xen:breadcrumb>

    I've tried it with and without full: but i got allways the same link
     
  6. Kier

    Kier XenForo Developer Staff Member

    If you don't use full: then the URL in the link will be relative and will not be useful for Google's microdata reader, which is used for SERPs.
     
  7. ragtek

    ragtek Guest

  8. ragtek

    ragtek Guest

    So this means, that the navbar links also should be "full", because the 2. breadcrumb element comes from the link, right?

    btw is there a way to manipulate this?
    I have a page, where i don't want to have this automatic in the breadcrumb, i only want my "own" elements which i defined in the template.
     

Share This Page