WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Templates, Menus & Design => Topic started by: swagmani on February 12, 2008, 02:26:43 AM

Title: Code Snippet: breadcrumb showing or not showing 1st level/or single menu items
Post by: swagmani on February 12, 2008, 02:26:43 AM
I was trying to limit the breadcrumbs output so as not to show first level menu items and after looking a little deeper into function  show_breadcrumbs()  and playing with the current parameters I didn’t think this was possible?

For my example I copied & renamed the function  show_breadcrumbs()  into my templates index.php as per below and added a new parameter to the beginning of the sequence of parameters in the function.

I imagine this conditional statement could be coded better/differently as it may not be aware of conditions for advanced situations?

          if (count($bca)==1 && $noRootLevel==1)

Regards,

Matt


Code: [Select]
<div class="breadcrumb">
    <?php
            
function show_breadcrumbsSpecial($noRootLevel=0,$sep=&#39; > &#39;,$tier=1,$links=true,$depth=-1) {
                
global $wb;
                
$page_id=$wb->page_id;
                if (
$page_id!=0)
                {
                    global 
$database;
                    
$bca=$wb->page_trail;
                    if (
count($bca)==&& $noRootLevel==1) {
                        echo &
#39;&nbsp;&#39;;
                    
} else {
                    echo &
#39;<b>You are here:</b>&nbsp;&#39;;
                        
$counter=0;
                        foreach (
$bca as $temp)
                        {
                            if (
$counter>=($tier-1) AND ($depth<OR $tier+$depth>$counter))
                            {
                                if (
$counter>=$tier) echo $sep;
                                
$query_menu=$database->query("SELECT menu_title,link FROM ".TABLE_PREFIX."pages WHERE page_id=$temp");
                                
$page=$query_menu->fetchRow();
                                if (
$links==true AND $temp!=$page_id)
                                    echo &
#39;<a href="&#39;.page_link($page[&#39;link&#39;]).&#39;">&#39;.$page[&#39;menu_title&#39;].&#39;</a>&#39;;
                                
else
                                    echo 
$page[&#39;menu_title&#39;];
                            
}
                            
$counter++;
                            }
                    }
                }
            }
        
show_breadcrumbsSpecial(1);?>
&nbsp;
</div>
Title: Re: Code Snippet: breadcrumb showing or not showing 1st level/or single menu ite
Post by: ruebenwurzel on February 12, 2008, 06:57:21 AM
Hello,

did you try it with a simply show_menu2 call? Look at the dokumentation of show_menu2, I'm pretty shure you can reach this with only one single line in your template, wich is much more better as to add whole functions in the template.

Matthias
Title: Re: Code Snippet: breadcrumb showing or not showing 1st level/or single menu ite
Post by: swagmani on February 12, 2008, 07:24:34 AM
Hi Matthias,

Quote
did you try it with a simply show_menu2 call? Look at the dokumentation of show_menu2, I'm pretty shure you can reach this with only one single line in your template, wich is much more better as to add whole functions in the template.

Matthias

I did look at the docs for 'show_menu2', there was 2 examples of breadcrumb but neither could turn off the breadcrumb output when viewing a first level menu item. I also read in another forum about another module for breadcrumbs but the link was dead;

So i thought this modified function was okay, perhaps like you say not the best solution adding a function into template but i figure whether this function is called or another similar function called its still processing time and well, this little function works.  :-)

cheers,

Matt
2-3days into website baker, finished 1 website, some php coding, css flyouts achieved and loving it...