priyeshrawal Posted July 1, 2009 Posted July 1, 2009 Hi guys, i wonder if any one of you know how to do this, say i have a box on my columns or an image, is there anyway to display this only if the customer was on a particular page, e.g. contact us and then if he moves on onto sitemap, then the boxes on the left or right hand column disappear, I know technically you can change the filename path of left column on contact us page to another one with that box (e.g. left_column1.php) and then do a different one for sitemap (e..g. left_column2.php) but this is annoying to make many different column files. is there a code that checks which page the customer is on and then when you use if function it can enable and disable a box depending on the page they are on?
germ Posted July 1, 2009 Posted July 1, 2009 Use basename($PHP_SELF) and entries from /includes/filenames.php like this: <?php switch ( basename($PHP_SELF) ) { case FILENAME_ACCOUNT: /* code if they're on account.php page here */ break; case FILENAME_ACCOUNT_EDIT: /* code if they're on account_edit.php page here */ break; default: /* default code if no other case matches here */ } ?> If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
priyeshrawal Posted July 4, 2009 Author Posted July 4, 2009 Thank you Germ for you advice, this makes alot more sense now.... however i am having a little difficulty finishing this off. could you give me an example by using a box,e.g. shopping cart or anything and adding it in the case file to show me how it should look in order to work! Thanks alot Use basename($PHP_SELF) and entries from /includes/filenames.php like this: <?php switch ( basename($PHP_SELF) ) { case FILENAME_ACCOUNT: /* code if they're on account.php page here */ break; case FILENAME_ACCOUNT_EDIT: /* code if they're on account_edit.php page here */ break; default: /* default code if no other case matches here */ } ?>
germ Posted July 4, 2009 Posted July 4, 2009 A working example: /catalog/includes/column_left.php Changing this code: require(DIR_WS_BOXES . 'information.php'); To: switch ( basename($PHP_SELF) ) { case FILENAME_CONTACT_US: case FILENAME_DEFAULT: require(DIR_WS_BOXES . 'information.php'); break; } Would show the information box only if they are on the main page (index.php) or the contact us (contact_us.php) pages. If you need a more precise example you'll have to tell me exactly what it is you want to include/exclude and where. Always backup a file before making any edits. If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
priyeshrawal Posted July 4, 2009 Author Posted July 4, 2009 you are a star!! no wait a genius. well i appreciate it. thanks, PM me if you do private contr acting. I have loads of tasks that may be interesting A working example: /catalog/includes/column_left.php Changing this code: require(DIR_WS_BOXES . 'information.php'); To: switch ( basename($PHP_SELF) ) { case FILENAME_CONTACT_US: case FILENAME_DEFAULT: require(DIR_WS_BOXES . 'information.php'); break; } Would show the information box only if they are on the main page (index.php) or the contact us (contact_us.php) pages. If you need a more precise example you'll have to tell me exactly what it is you want to include/exclude and where. Always backup a file before making any edits.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.