Skip to content

Instantly share code, notes, and snippets.

@GreatPotato
Last active December 31, 2015 03:29
Show Gist options
  • Select an option

  • Save GreatPotato/7928022 to your computer and use it in GitHub Desktop.

Select an option

Save GreatPotato/7928022 to your computer and use it in GitHub Desktop.
Create basic breadcrumb with page blocks in LemonStand
// Create a page block called "breadcrumb"
<?php $category = isset($product) ? $product->categories[0] : null; ?>
<?php if($category): ?>
<?php foreach ($category->get_parents() as $parent): ?>
<li><a href="<?php echo $parent->page_url('/category') ?>"><?php echo h($parent->name); ?></a></li>
<?php endforeach; ?>
<li><a href="<?php echo $category->page_url('/category'); ?>"><?php echo h($category->name); ?></a></li>
<?php endif; ?>
<?php if($product): ?>
<li class="active"><a href="<?php echo $product->page_url('/product'); ?>"><?php echo h($product->name); ?></a></li>
<?php endif; ?>
// Output in your layout as so:
<ul class="breadcrumb pull-right">
<li>
<a href="<?php echo site_url('/'); ?>">Home</a>
</li>
<?php $this->render_block('breadcrumb'); ?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment