Breadcrumbs for MLE

Breadcrumbs for the MleCMS module.

When you're using the MleCMS module, the breadcrumbs tag's lack of flexibility makes it impossible for you to use it. Besides, the breadcrumbs tag is marked deprecated in CMS made simple 1.11. E.g. calling it without parameters will show: English >> Page >> Subpage.

To get rid of the language name in your breadcrumbs, here's a solution combining the power of the menu tag and a UDT. First we emulate the root parameter you used to have to make a page (e.g. the front page) appear to be the root of everything even though it is not. Assuming the first child of every language is your front page the following UDT does the job:

$hm = cmsms()->getHierarchyManager();
$position = substr($smarty->get_template_vars('position'), 0, 1) . '.1';
$node = $hm->getNodeByHierarchy($position);
$id = $node->getId();
if($params['assign'])
{
    $smarty->assign($params['assign'], $id);
}
else
{
    echo $id;
}

Add the UDT to your multi-language CMS and call it get_home_id. Next create a menu template called breadcrumbs using the following code:

{if $count > 0}
<p class="breadcrumbs">
{get_home_id assign="home"}{if $content_id != $home}{cms_selflink page=$home title=""} › {/if}
{foreach from=$nodelist item=node name="mainmenu"}
{if $node->depth > 1}
{if $node->current}
<span>{$node->menutext}</span>
{elseif $node->parent}
<a href="{$node->url}">{$node->menutext}</a> › 
{/if}
{/if}
{/foreach}
</p>
{/if}

Perfect! Call the breadcrumbs like {menu template="breadcrumbs" loadprops=0 collapse=1}.

ALL-INKL.COM - Webhosting Server Hosting Domain Provider

Comments