Documentation

Light-weight, fast, simple and powerful!
 
Translations of this page?:

display a breadcrumb using Wolf's internal function

Wolf has a small and simple piece of code ready-made for displaying breadcrumbs:

<?php echo $this->breadcrumbs(); ?>

Put it in your Layout where you want the breadcrumbs to appear.

If you want to use a different separator, do it like this:

<?php echo $this->breadcrumbs('-'); ?>

You can use any symbol you like as the separator (plus, minus, colon, semicolon, etc.), as long as you keep it between the quote marks inside the braces: ('here').

If you want to use a backslash as the separator, it needs to be “escaped”, that is, written twice:

$this->breadcrumbs('\\');

display a breadcrumb manually with rich snippets

Currently Wolf doesn't use Rich Snippets with its internal functions. If you wish to use them, you'll have to create your own function. The function below, for example, will use Wolf's internal function and then modify it to include the rich snippets in MicroData form:

<ul class="breadcrumb">
<?php
$explode = explode("&raquo;</span>", $this->breadcrumbs('&raquo;'));
 
foreach ($explode as $key => $val) {
	$val = preg_replace("/<span[^>]+\>/i", "", $val);
	$val = str_replace("</span>", "", $val);
 
	$pattern = '#<a href="(.+)" title="(.+)">#';
	if (preg_match($pattern, $val, $breadcrumb) > 0) {
?>
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span class="separator">&raquo; </span><a href="<?php echo $breadcrumb[1]; ?>" title="<?php echo $breadcrumb[2]; ?>" itemprop="url"><span itemprop="title"><?php echo $breadcrumb[2]; ?></span></a></li>
<?php    
	}
	else {
?>
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span class="separator">&raquo; </span><a href="<?php echo $this->url(); ?>" title="<?php echo $val; ?>" itemprop="url"><span itemprop="title"><?php echo $val; ?></span></a></li>
<?php 
	}
}
?>
</ul>

mtylerb 2013-01-24 17:24

 
howto/display_a_breadcrumb.txt · Last modified: 2013-09-08 23:44 by David
 
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2
Copyright 2010 wolfcms.org / design by yello studio / Wolf CMS Inside