/** * @return Breadcrumbs */ public function testInitBreadcrumbs() { $breadcrumbs = new Breadcrumbs(); $breadcrumbs->add('home', '/home/'); $breadcrumbs->add('profile', '/profile/'); $breadcrumbs->add('address'); return $breadcrumbs; }
/** * @return BreadcrumbsInterface */ public function testAddWithFluentInterface() { $breadcrumbs = new Breadcrumbs(); $breadcrumbs->add('home', '/home/')->add('profile', '/profile/')->add('address'); return $breadcrumbs; }
<?php // start session session_start(); use Naucon\Breadcrumbs\Breadcrumbs; use Naucon\Breadcrumbs\Handler\BreadcrumbHandlerSession; $breadcrumbs = new Breadcrumbs(); $breadcrumbs->setBreadcrumbHandler(new BreadcrumbHandlerSession()); if ($breadcrumbs->count() > 4) { $breadcrumbs->clear(); } $breadcrumbs->add(date('H:i:s'), '/home/'); foreach ($breadcrumbs as $breadcrumb) { if ($breadcrumb->hasUrl()) { echo '<a href="' . $breadcrumb->getUrl() . '">' . $breadcrumb->getTitle() . '</a>'; } else { echo $breadcrumb->getTitle(); } echo ' '; } echo '<br/>' . PHP_EOL; // close session session_write_close();
<?php use Naucon\Breadcrumbs\Breadcrumbs; $breadcrumbs = new Breadcrumbs(); $breadcrumbs->add('home', '/home/'); $breadcrumbs->add('profile', '/profile/'); $breadcrumbs->add('address'); foreach ($breadcrumbs as $breadcrumb) { if ($breadcrumb->hasUrl()) { echo '<a href="' . $breadcrumb->getUrl() . '">' . $breadcrumb->getTitle() . '</a>'; } else { echo $breadcrumb->getTitle(); } echo ' '; } echo '<br/>' . PHP_EOL; use Naucon\Breadcrumbs\Helper\BreadcrumbsHelper; $breadcrumbsHelper = new BreadcrumbsHelper($breadcrumbs); echo $breadcrumbsHelper->render(); echo '<br/>' . PHP_EOL; // with separator $breadcrumbsHelper->setSeparator(' / '); echo $breadcrumbsHelper->render(); echo '<br/>' . PHP_EOL; // with span tag and separator $breadcrumbsHelper->setTag('span'); $breadcrumbsHelper->setSeparator(' / '); echo $breadcrumbsHelper->render(); echo '<br/>' . PHP_EOL; // with div tag and separator $breadcrumbsHelper->setTag('div');