It's easier to explaing if you consider a structure like this...
If you look at the Article 1 page, your standard breadrumb would look like this (bold indicates a <a> link):Home
-- Section 1
-- Section 2
---- Article 1 ('default' in this section)
---- Article 2
---- Article 3
---- Article 4
OK, that's cool. But when you click down 1 link further, say to Article 3, the breadcrumb does not change. This may be fine for many setups, but if like me your 'default' article in a section acts as a home page for the section in question, this may not be enough.Home > Section 2 > Article 1
The amendment below will allow you to create the following breadcrumbs.
Example 1(looking at the 'default' article in the Section 2 section):
This indicates that the level above you is the Home page.Home >
Example 2(looking at Article 3, in Section 2):
This indicates that you have drilled down from the home page, to Section 2, and then on down to Article 3.Home > Section 2 >
The amendment to the code also adds a title attribute to each link tag, so in example 2 above, hovering over the Section 2 link would produce the following 'tooltip' in the same way as an alt attribute of an image would:
This might not be what you're after for your own sites, but here's the amended code if you're interested...Back up to Section 2 page
Open /include/inc_front/front.func.inc.php and replace the following if/else block...
Code: Select all
if(sizeof($crumbs_part)) {
$breadcrumb = "";
foreach($crumbs_part as $key => $value) {
$alias = '';
if ($act_id != $key) {
if($breadcrumb) $breadcrumb .= $spacer;
if(!$struct_array[$key]["acat_redirect"]) {
$breadcrumb .= '<a href="index.php?';
$alias = $struct_array[$key]["acat_alias"];
$breadcrumb .= ($alias) ? html_specialchars($alias) : 'id='.$key.',0,0,1,0,0';
$breadcrumb .= '">';
} else {
$redirect = get_redirect_link($struct_array[$key]["acat_redirect"], ' ', '');
$breadcrumb .= '<a href="'.$redirect['link'].'"'.$redirect['target'].'>';
}
$breadcrumb .= html_specialchars($crumbs_part[$key]).'</a>';
} else {
if($breadcrumb) $breadcrumb .= $spacer;
$breadcrumb .= html_specialchars($crumbs_part[$key]);
}
}
} else {
$breadcrumb = "";
}
Code: Select all
if(sizeof($crumbs_part)) {
$breadcrumb = "";
foreach($crumbs_part as $key => $value) {
$alias = '';
if ($act_id != $key) {
if($breadcrumb) $breadcrumb .= $spacer;
if(!$struct_array[$key]["acat_redirect"]) {
$breadcrumb .= '<a href="index.php?';
$alias = $struct_array[$key]["acat_alias"];
$breadcrumb .= ($alias) ? html_specialchars($alias) : 'id='.$key.',0,0,1,0,0';
// added a title attribute here that draws its content from the category name
$breadcrumb .= '" title="Go back up to the '.html_specialchars($crumbs_part[$key]).' page">';
} else {
$redirect = get_redirect_link($struct_array[$key]["acat_redirect"], ' ', '');
// added a title attribute here that draws its content from the category name
$breadcrumb .= '<a href="'.$redirect['link'].'"'.$redirect['target'].' title="Go back up to the '.html_specialchars($crumbs_part[$key]).' page">';
}
$breadcrumb .= html_specialchars($crumbs_part[$key]).'</a>';
} else {
/*
edited code here to check the number "." characters in the url
this assumes that rewrite is turned on and you links look like this:
13.7.0.0.0.0.shtml for an article
aliasname.shtml for a section that has the alias 'aliasname'
if rewrite is turned off and your links look like this:
index.php?id=13,7,0,0,0,0 for an article
index.php?aliasname for a section that has the alias 'aliasname'
you'll need to uncomment the lines below
*/
$querystring = $_SERVER['QUERY_STRING']; // get qs value
if($querystring != "index") $breadcrumb .= $spacer; // append spacer character if required
// uncomment the line below this if you need to but remember to comment out the one below it too!
// if(substr_count($querystring, ",") == 5) $breadcrumb .= '<a href="index.php?'.$struct_array[$key]["acat_alias"].'" title="Go back up to the '.html_specialchars($crumbs_part[$key]).' page">'.html_specialchars($crumbs_part[$key]).'</a>'.$spacer;
if(substr_count($querystring, ".") == 5) $breadcrumb .= '<a href="'.$struct_array[$key]["acat_alias"].'.shtml" title="Go back up to the '.html_specialchars($crumbs_part[$key]).' page">'.html_specialchars($crumbs_part[$key]).'</a>'.$spacer;
}
}
} else {
$breadcrumb = "";
}
Hope this helps somebody as much as it has mealiasname.shtml translates to index.php?aliasname
13.6.0.0.1.0.shtml translates to index.php?id=13,6,0,0,1,0
