Breadcrumb in Admin Template

hello,
I am rather new to Xenforo and I am just developing an admin add-on.
I would like to have a breadcrumb menu on top of the admin template and don't know how to manage this.
As far as I can see, my template has to be embedded in the PAGE_CONTAINER, because the latter includes the content_header subtemplate, which displays the breadcrumb menu.
Any idea how to manage this?
thanks for your help, Helmut
 
This is how I added breadcrumbs to my templates:
Code:
<xen:navigation>
    <xen:breadcrumb href="{xen:link page}">{xen:phrase page}</xen:breadcrumb>
</xen:navigation>
 
This is how I added breadcrumbs to my templates:
Code:
<xen:navigation>
    <xen:breadcrumb href="{xen:link page}">{xen:phrase page}</xen:breadcrumb>
</xen:navigation>

is this the only way? when I look at the *official* admin templates, there is no breadcrumb tag..
 
You can provide a source array to build them from in your controller:
Code:
<xen:navigation>
    <xen:breadcrumb source="$nodeBreadCrumbs" />
</xen:navigation>

I don't have access to the admin templates at the moment, but that should work.
 
To get the breadcrumbs to show automatically in the AdminCP for your add-on you do not need the <xen:navigation> tag, this is handled by the route/prefixadmin/name_of_your_addon.php file. The reason yours is not showing is you do not have the admin navigation id for your add-on set in the route admin prefix handler (or there is a typo there).

PHP:
class IcewindDaleRP_IcewindDale_Route_PrefixAdmin_ShopItems implements XenForo_Route_Interface
{
    public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
    {
        $action = $router->resolveActionWithIntegerParam($routePath, $request, 'item_id');
        return $router->getRouteMatch('IcewindDaleRP_IcewindDale_ControllerAdmin_ShopItems', $action, 'iwdShopItems');
    }

    public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
    {
        return XenForo_Link::buildBasicLinkWithIntegerParam($outputPrefix, $action, $extension, $data, 'item_id', 'name');
    }
}

The admin navigation id for my shop add-on above is: 'iwdShopItems' . If i change that id, the breadcrumbs disappear. Here is the top portion of my admin template for listing shop items, as you can see, no <xen:navigation> tag is used:

HTML:
<xen:title>{xen:phrase iwd_shop_items}</xen:title>

<xen:topctrl>
<xen:if is="{$images}">
    <a href="{xen:adminlink iwd-shop-items/add}" class="button">+ {xen:phrase iwd_create_new_item}</a>
</xen:if>
    <a href="{xen:adminlink iwd-shop-items/upload}" class="button">+ {xen:phrase iwd_upload_image}</a>
</xen:topctrl>

<xen:require css="filter_list.css" />
<xen:require js="js/xenforo/filter_list.js" />

<xen:form action="{xen:adminlink iwd-shop-items/toggle}" class="section AutoValidator">

And here is the SS showing the breadcrumb:
admin_image.webp

When I select an item to edit, I do then use the <xen:navigation> tag in my shops add/edit template to show the editing item in the breadcrumb:
HTML:
<xen:require css="iwd_shop.css" />
<xen:title>{xen:if '{$item.item_id}', '{xen:phrase iwd_edit_item}: {$item.item_name}', '{xen:phrase iwd_create_new} {$item.item_type}'}</xen:title>

<xen:if is="{$item.item_id}">
    <xen:navigation>
        <xen:breadcrumb href="{xen:adminlink iwd-shop-items}#{xen:helper listitemid, $item.item_id}">{$item.item_name}</xen:breadcrumb>
    </xen:navigation>
</xen:if>
and that results in:
Image_1.webp
 
You can provide a source array to build them from in your controller:
Code:
<xen:navigation>
    <xen:breadcrumb source="$nodeBreadCrumbs" />
</xen:navigation>

I don't have access to the admin templates at the moment, but that should work.

The variable $nodeBreadCrumbs is empty, so this does not work.
 
You can provide a source array to build them from in your controller:
Code:
<xen:navigation>
    <xen:breadcrumb source="$nodeBreadCrumbs" />
</xen:navigation>

I don't have access to the admin templates at the moment, but that should work.

Could you give me a clue of how to define the value of the $nodeBreadCrumbs variable?
 
Could you give me a clue of how to define the value of the $nodeBreadCrumbs variable?

I use this in my controller.
Code:
        $breadCrumbs['roster'] = array(
            'value' => 'Roster',
            'href' => XenForo_Link::buildAdminLink('full:roster')
        );

You can copy paste this code more time that will add more links in your breadcrumbs like this:
Code:
        $breadCrumbs['roster'] = array(
            'value' => 'Roster',
            'href' => XenForo_Link::buildAdminLink('full:roster')
        );
        $breadCrumbs['nieuwteam'] = array(
            'value' => 'Nieuw team',
            'href' => XenForo_Link::buildAdminLink('full:roster/nieuwteam')
        );


After you do that just send it to the template with:
Code:
        $viewParams = array(
            'breadCrumbs' => $breadCrumbs,
        );

And use in your template:
Code:
<xen:navigation>
    <xen:breadcrumb source="$breadCrumbs" />
</xen:navigation>

I think there are better ways but it is working.
 
Top Bottom