Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How do I determine the page name?


hunterchief

Recommended Posts

Programatically speaking, from within any routine, can I determine which page I am processing. I would like to know, for example, within the tep_image() function if the image being rendered is for the home page.

 

something like:

 

if ($current_page = 'home')

 

I found myself writing this, which I would like to avoid:

 

if ($_SERVER["PHP_SELF"] == '/index.php' && strpos($_SERVER["REQUEST_URI"], '.html') === FALSE) // Only on the home page

Link to comment
Share on other sites

ok, cool... FILENAME_DEFAULT is useful.

 

But if we say FILENAME_DEFAULT = index.php, there are other pages using the SEO URLs (movies-cartoons-c-3_13.html) that get remapped to index.php and are not considered the "home" page; like the product listing in the movies-cartoon example here.

Link to comment
Share on other sites

movies-cartoons-c-3_13.html isn't a page, it's a category tha is displayed using the index.php file. If you want to check for a category, you have to check the code on that page (see cPath variable).

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

$_SERVER['PHP_SELF'] is unreliable better to use $_SERVER['SCRIPT_NAME']

 

  if( (basename($_SERVER['SCRIPT_NAME']) == FILENAME_DEFAULT) && $category_depth == 'top' ){
  echo 'This is the default page';
 }

 

The above code can only be used inside the index.php file after $category_depth has been set. This must be the case however based on your needs being based upon tep_image().

 

Within the tep_image function you will need to set $category_depth as global

 

  function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') {
 global $category_depth;

 

The code in tep_image would look similar to ..

 

  if( isset($category_depth) && (basename($_SERVER['SCRIPT_NAME']) == FILENAME_DEFAULT) && $category_depth == 'top' ){
  echo 'This is for the default page';
 }

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...