Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Breadcrumb when no record number in URL

 

 


theclicklab
User

Jan 7, 2012, 1:59 PM

Post #1 of 2 (215 views)
Shortcut
Breadcrumb when no record number in URL Can't Post

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:


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 ): ?> &rsaquo;
<?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
~~~~~~~~~~~~~~~~~~
Jan Dunlop
theClickLab.com
nz.linkedin.com/in/jandunlop
~~~~~~~~~~~~~~~~~~


Jason
Staff / Moderator


Jan 8, 2012, 6:02 PM

Post #2 of 2 (204 views)
Shortcut
Re: [theclicklab] Breadcrumb when no record number in URL [In reply to] Can't Post

Hi,

You could try to use $selectedCategory instead of getting the number from the Url:


Code
<div class="breadcrumb">  
<a href="/">Home</a>
<?php foreach ( $breadcrumbRecords as $breadcrumb ): ?> &rsaquo;
<?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 - Programmer 
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/