Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / How to determine current page

How to determine current page

Locked

Views: 4,906

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
14 Nov 2008, 10:39 PM
#1
mygreygoose avatar

mygreygoose

New Zenner

Join Date:
Jun 2007
Posts:
91
Plugin Contributions:
0

How to determine current page

I'm trying to remove the categories navigation once the customer gets to the checkout and beyond. Unless someone has a better suggestion, what I'd like to do is an IF statement along the lines of:

if NOT current page = main_page=checkout_shipping OR NOT current page = main_page=checkout_payment

Then: // show the categories naviation

<div id="navColumnOneWrapper" style="width: <?php echo BOX_WIDTH_LEFT; ?>"><?php require(DIR_WS_MODULES . zen_get_module_directory('column_left.php')); ?></div>

Else // don't show categories navigation

<div id="navColumnOneWrapper" style="width: <?php echo BOX_WIDTH_LEFT; ?></div>

The problem is, I can't figure out how to determine the current page. Is there a php or Zen function that does this? I tried $server([self] (or something like that) but it only returned "index.php" ... not the URL

14 Nov 2008, 10:58 PM
#2
edadk avatar

edadk

Zen Follower

Join Date:
Nov 2008
Posts:
191
Plugin Contributions:
0

Re: How to determine current page

Try using this:

 $_SERVER['REQUEST_URI'];

Ed

14 Nov 2008, 11:01 PM
#3
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: How to determine current page

MyGreyGoose:

I'm trying to remove the categories navigation once the customer gets to the checkout and beyond. Unless someone has a better suggestion, what I'd like to do is an IF statement along the lines of:

if NOT current page = main_page=checkout_shipping OR NOT current page = main_page=checkout_payment

Then: // show the categories naviation

<div id="navColumnOneWrapper" style="width: <?php echo BOX_WIDTH_LEFT; ?>"><?php require(DIR_WS_MODULES . zen_get_module_directory('column_left.php')); ?></div>

Else // don't show categories navigation

<div id="navColumnOneWrapper" style="width: <?php echo BOX_WIDTH_LEFT; ?></div>

The problem is, I can't figure out how to determine the current page. Is there a php or Zen function that does this? I tried $server([self] (or something like that) but it only returned "index.php" ... not the URL

I'm guessing that you mean to just turn off the categories sidebox? Or do you want to disable the entire left side column?

14 Nov 2008, 11:17 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How to determine current page

You can get the results of what the current page is with:
$current_page

14 Nov 2008, 11:29 PM
#5
mygreygoose avatar

mygreygoose

New Zenner

Join Date:
Jun 2007
Posts:
91
Plugin Contributions:
0

Re: How to determine current page

@Ajeh Thanks Linda! That worked. I thought I had already tried that and it didn't work... but I guess you brought some luck.

@Clyde I'm thinking the entire left column since those are all "distractions" during checkout. I'm currently trying this on tpl_main_page where it calls the navColumnOneWrapper box. I'll post back the code for others if I can get this to work (and for others to critique / offer better alternatives).

@Ed Thanks - yours worked too (exactly what I asked for ... "/index.php?main_page=checkout_shipping"). Linda's returns just the checkout_shipping part which works best for my evaluation needs.

14 Nov 2008, 11:46 PM
#6
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: How to determine current page

MyGreyGoose:

@Ajeh Thanks Linda! That worked. I thought I had already tried that and it didn't work... but I guess you brought some luck.

@Clyde I'm thinking the entire left column since those are all "distractions" during checkout. I'm currently trying this on tpl_main_page where it calls the navColumnOneWrapper box. I'll post back the code for others if I can get this to work (and for others to critique / offer better alternatives).

@Ed Thanks - yours worked too (exactly what I asked for ... "/index.php?main_page=checkout_shipping"). Linda's returns just the checkout_shipping part which works best for my evaluation needs.

@Clyde I'm thinking the entire left column since those are all "distractions" during checkout. I'm currently trying this on tpl_main_page where it calls the navColumnOneWrapper box. I'll post back the code for others if I can get this to work (and for others to critique / offer better alternatives).*
open includes/templates/YOUR_TEMPLATE/common/ tpl_main_page.php

find this line of code (near the top of the file)

// the following IF statement can be duplicated/modified as needed to set additional flags
  if (in_array($current_page_base,explode(",",'list_pages_to_skip_all_right_sideboxes_on_here,separated_by_commas,and_no_spaces')) ) {
    $flag_disable_right = true;
  }

Replace the highlighted portion with this:

  if (in_array($current_page_base,explode(",",'checkout_shipping,checkout_payment,checkout_confirmation,checkout_success')) ) {
    $flag_disable_left = true;
  }

This should turn off the left column whenever you get to the checkout section.

14 Nov 2008, 11:52 PM
#7
mygreygoose avatar

mygreygoose

New Zenner

Join Date:
Jun 2007
Posts:
91
Plugin Contributions:
0

Re: How to determine current page

Darn - wish I saw your post first. I got it to work with the following code, but yours seems better. Will try that too.

 <td id="navColumnOne" class="columnLeft" style="width: <?php echo COLUMN_WIDTH_LEFT; ?>">
<?php
 /* prepares and displays left column sideboxes if not during checkout */
 
 if ($current_page != 'checkout_shipping' && $current_page != 'checkout_payment' && $current_page != 'checkout_confirmation') { ?>
<div id="navColumnOneWrapper" style="width: <?php echo BOX_WIDTH_LEFT; ?>"><?php require(DIR_WS_MODULES . zen_get_module_directory('column_left.php')); ?></div>
 <?php }
?>