hunterchief Posted August 8, 2008 Share Posted August 8, 2008 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 More sharing options...
Jack_mcs Posted August 8, 2008 Share Posted August 8, 2008 Try if (basename($PHP_SELF) == FILENAME_DEFAULT) 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 More sharing options...
hunterchief Posted August 11, 2008 Author Share Posted August 11, 2008 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 More sharing options...
Jack_mcs Posted August 11, 2008 Share Posted August 11, 2008 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 More sharing options...
♥FWR Media Posted August 11, 2008 Share Posted August 11, 2008 $_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'; } Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls KissMT Dynamic SEO Meta & Canonical Header Tags KissER Error Handling and Debugging KissIT Image Thumbnailer Security Pro - Querystring protection against hackers ( a KISS contribution ) If you found my post useful please click the "Like This" button to the right. Please only PM me for paid work. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.