Breadcrumb when no record number in URL
2 posts by 2 authors in: Forums > CMS Builder
Last Post: January 8, 2012 (RSS)
Hi there,
I'm having an issue getting a breadcrumb working - I think its due to the fact that I don't have the record number in the url?
Page URL's are formatted as: www.xyz.com/abc/
Here's the code:
Any suggestions?
Many thanks
I'm having an issue getting a breadcrumb working - I think its due to the fact that I don't have the record number in the url?
Page URL's are formatted as: www.xyz.com/abc/
Here's the code:
// load breadcrumbs
list($breadcrumbRecords, $selectedCategory) = getCategories(array(
'tableName' => 'pages', // REQUIRED
'categoryFormat' => 'breadcrumb', // showall, onelevel, twolevel, breadcrumb
));
<div class="breadcrumb">
<a href="/">Home</a>
<?php foreach ( $breadcrumbRecords as $breadcrumb ): ?> ›
<?php if ( $breadcrumb['num'] != getLastNumberInUrl() ): ?><a href="/<?php echo strtolower($breadcrumb['url']); ?>/"><?php endif ?>
<?php echo $breadcrumb['name']; ?>
<?php if ( $breadcrumb['num'] != getLastNumberInUrl() ): ?></a><?php endif ?>
<?php endforeach ?>
</div>
Any suggestions?
Many thanks
Re: [theclicklab] Breadcrumb when no record number in URL
By Jason - January 8, 2012
Hi,
You could try to use $selectedCategory instead of getting the number from the Url:
However, in order for this to work, you'll need to either have a number in the Url, or you have to set selectedCategoryNum in your getCategories call.
Hope this helps
You could try to use $selectedCategory instead of getting the number from the Url:
<div class="breadcrumb">
<a href="/">Home</a>
<?php foreach ( $breadcrumbRecords as $breadcrumb ): ?> ›
<?php if ( $breadcrumb['num'] != @$selectedCategory['num'] ): ?><a href="/<?php echo strtolower($breadcrumb['url']); ?>/"><?php endif ?>
<?php echo $breadcrumb['name']; ?>
<?php if ( $breadcrumb['num'] != @$selectedCategory['num'] ): ?></a><?php endif ?>
<?php endforeach ?>
</div>
However, in order for this to work, you'll need to either have a number in the Url, or you have to set selectedCategoryNum in your getCategories call.
Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/