With the example provided for breadcrumbs, I have a requirement for the last item to not be clickable.
<nav class="breadcrumb" role="navigation">
<ul>
<?php foreach($site->breadcrumb() as $crumb): ?>
<li>
<a href="<?php echo $crumb->url() ?>">
<?php echo html($crumb->title()) ?>
</a>
</li>
<?php endforeach ?>
</ul>
</nav>
How would I achieve this?
(Sorry if it seems simple, but I am new to Kirby & PHP but it seems like a nice simple CMS to play with so I am trying to learn some things).
Try this:
<nav class="breadcrumb" role="navigation">
<ul>
<?php foreach($site->breadcrumb() as $crumb): ?>
<li>
<?php if($crumb->is($site->breadcrumb()->last())): ?>
<?php echo html($crumb->title()) ?>
<?php else: ?>
<a href="<?php echo $crumb->url() ?>">
<?php echo html($crumb->title()) ?>
</a>
<?php endif ?>
</li>
<?php endforeach ?>
</ul>
</nav>
(not tested)
1 Like
Ah there is a β->last()β - but unfortunately your example raises a - syntax error, unexpected β:β
I can dive deeper into this if you donβt have the fix off hand.
Ah, sorry, my favorite missing parens error, corrected above.
Ah yes, well spotted 
Thank you for providing this. I hope to learn more about Kirby and start to use it in the future.