jimbobsquarepants Posted August 25, 2006 Share Posted August 25, 2006 I've only been playing with PHP for about 4 months so im slowly getting there.On my test website i've made a breadcrumb trail ... for example it might look something like thisHome >> Customer Information >> Help >> FAQs.Is it poss to do an if statement on the trail?So if the breadcrumb trail says Help then do a song and dance ;DCheers Link to comment https://forums.phpfreaks.com/topic/18632-breadcrumb/ Share on other sites More sharing options...
HuggieBear Posted August 25, 2006 Share Posted August 25, 2006 Anything's possible ;)It sounds as though you could stick the if statement in there without much trouble. Obviously it depends on how you're generating the breadcrumb in the first place, but yeah, should be easy enough.Rich Link to comment https://forums.phpfreaks.com/topic/18632-breadcrumb/#findComment-80267 Share on other sites More sharing options...
jimbobsquarepants Posted August 25, 2006 Author Share Posted August 25, 2006 Rich thanks for that ...what kinda info do you need to know to help me with the code?Cheers Link to comment https://forums.phpfreaks.com/topic/18632-breadcrumb/#findComment-80270 Share on other sites More sharing options...
HuggieBear Posted August 25, 2006 Share Posted August 25, 2006 Ideally the code you're using to generate the breadcrumb. Then we can point you in the right direction.Rich Link to comment https://forums.phpfreaks.com/topic/18632-breadcrumb/#findComment-80271 Share on other sites More sharing options...
jimbobsquarepants Posted August 25, 2006 Author Share Posted August 25, 2006 Think thats the bit you need<?php/* $Id: breadcrumb.php,v 1.3.2.5 2004/09/20 14:21:29 tds Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License*/ class breadcrumb { var $_trail; function breadcrumb() { $this->reset(); } function reset() { $this->_trail = array(); } function add($title, $link = '') { $this->_trail[] = array('title' => $title, 'link' => $link); } function trail($separator = ' - ') { $trail_string = ''; for ($i=0, $n=sizeof($this->_trail); $i<$n; $i++) { if (isset($this->_trail[$i]['link']) && tep_not_null($this->_trail[$i]['link'])) { $trail_string .= '<a href="' . $this->_trail[$i]['link'] . '" class="headerNavigation">' . $this->_trail[$i]['title'] . '</a>'; } else { $trail_string .= $this->_trail[$i]['title']; } if (($i+1) < $n) $trail_string .= $separator; } return $trail_string; } function custom_file($webdir, $base) { // Note: needs to be global. Needs not to be initialised to anything. global $badgermushroom; // apols for silly variable name, needs to be // unique. global $STICKY_CUSTOM_FILES; tep_session_register("badgermushroom"); if (!$badgermushroom) { $badgermushroom = array(); } $append = ""; for($i=0, $n=sizeof($this->_trail) ; $i < $n ; ++$i) { $safe = $this->_trail[$i]['title']; $safe = ereg_replace('[^a-zA-Z0-9]+', '_', $safe); $safe = strtolower($safe); $append = $append.$safe."-"; $test = $webdir.$append.$base; if(file_exists($test)) { $result = $badgermushroom[$base] = $webdir.$append.$base; return $result; } }; // default result $result = $webdir.$base; if (!$badgermushroom[$base]) { $badgermushroom[$base] = $result; }; if ($STICKY_CUSTOM_FILES) { // then we "stick" to the last look-and-feel return $badgermushroom[$base]; } else { error_log("saying (default) ".$result); return $result; }; return; // we never get here. } function string_only($separator="-") { $string=""; for($i=0, $n=sizeof($this->_trail) ; $i < $n ; ++$i) { $safe = $this->_trail[$i]['title']; $safe = ereg_replace('[^a-zA-Z0-9]+', '_', $safe); $safe = strtolower($safe); if(strlen($string)) { $string .= $separator; } $string .= $safe; } return $string; } function is_part($base) { $append = ""; for($i=0, $n=sizeof($this->_trail) ; $i < $n ; ++$i) { $safe = $this->_trail[$i]['title']; $safe = ereg_replace('[^a-zA-Z0-9]+', '_', $safe); $safe = strtolower($safe); if($append == "") { $append = $safe; } else { $append = $append."-".$safe; } if($append == $base) { return 1; } } return 0; } } ?> Link to comment https://forums.phpfreaks.com/topic/18632-breadcrumb/#findComment-80274 Share on other sites More sharing options...
jimbobsquarepants Posted August 25, 2006 Author Share Posted August 25, 2006 and then in the header i echo $breadcrumb->trail(' » ');cheers Link to comment https://forums.phpfreaks.com/topic/18632-breadcrumb/#findComment-80275 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.