Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Breadcrumb problem: Custom function needed?


westkoast

Recommended Posts

I recently pulled my store down the root level, and am using the header.php file site wide. My problem is that now on the "home" page...home.php it reads "Top >> Catalog"

 

I figured out that if one comments out the second line of the $breadcrumb in appication_top.php it "Catalog" part will go away, but it also goes away on ALL pages....and I'd rather not manually insert it onto all pages.

 

Is there an "if, else" statment that I could put in application_top.php that would allow me to NOT show "catalog" in the breadcrumb when I'm on the home page, and then show it everywhere else?

 

 

Say something like this:

(NOT real code, or any language...just an idea)

 

if (page == home){

$breadcrumb = home;

}

 

else{

$breadcrumb = home;

$breadcrumb = catalog;

}

I need to read the rules more often...

Link to comment
Share on other sites

In includes/application_top.php, im not sure what line it is as standard (looking at a modded version right now) there is a section of code like this (roughly line 400-500:

 

require(DIR_WS_CLASSES . 'breadcrumb.php');

 $breadcrumb = new breadcrumb;



 $breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER);

 $breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT));

 

Replace this with:

 

require(DIR_WS_CLASSES . 'breadcrumb.php');

 $breadcrumb = new breadcrumb;



if (basename($REQUEST_URI) != FILENAME_DEFAULT)) {

 $breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link

(FILENAME_DEFAULT));

}

 

I think...

Regards, Jay.

Link to comment
Share on other sites

Sorry westkoast, i was rushing when i wrote this. Looks like i've added an extra ) in there that shouldnt be there. Should be:

 

require(DIR_WS_CLASSES . 'breadcrumb.php'); 

 $breadcrumb = new breadcrumb; 



if (basename($REQUEST_URI) != FILENAME_DEFAULT) { 

 $breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT)); 

}

 

The function basename() in a literal sense returns the filename component of the supplied path. This means it will extract the filename from a given path.

 

In this case im using the PHP variable $REQUEST_URI which will return the current directory path starting from the root. So if you are on:

 

http://www.mydomain.com/path/to/filename.php?variable=1

 

$REQUEST_URI will return:

 

filename.php?variable=1

 

Now you dont want the breadcrumb to be added on the index page, however that page is called when browsing categories, which obviously you DO want the breadcrumb to display. So my code checks to see if the current filename equates to JUST the name of your index, without any URL posted variables.

 

Is that any clearer?

Regards, Jay.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...