zen cart — How to determine if current page is HomePage?

sometims,you need to know if the current page is homepage. for example,you don’t want to show some special content in the homepage,then you need to know whether the current page is homepage.

From zen cart source code,i got some idea,see it below

[codesyntax lang=”php”]

$this_is_home_page = ($current_page=='index' && (!isset($_GET['cPath'])) && (!isset($_GET['manufacturers_id'])) && (!isset($_GET['typefilter'])) );


so we can get the result from $this_is_home_page.  this is a global varaible,so you can access it if it’s initiated.


zen cart — How to Add a Sidebox to Zen Cart

One of the best way to customize Zen Cart is to create a new Sidebox.A Zen Cart sidebox is what displays various contents in the left or right columns of your Zen Cart store. By default numerous sideboxes will show in either the left or right column of a Zen Cart online store. The followings are some of the most popular zen cart sidebox — The categories sidebox, the search sidebox, and the information sidebox. Zen cart comes with some builtin sidebox which could be a good tutor to start to learn how to add a new sidebox to Zen Cart.

A sidebox consists of three files which are located in the includes directory:

  1. modules/sideboxes/YOUR_TEMPLATE/new_sidebox.php
  2. languages/english/extra_definitions/YOUR_TEMPLATE/new_sidebox_defines.php
  3. templates/YOUR_TEMPLATE/sideboxes/tpl_new_sidebox.php

The ‘new’ up there should be replaced with your own sidebox name.


[codesyntax lang=”php”]

 $show_new_sidebox = true;
 if ($show_new_sidebox == true){
   $current_page_base,'sideboxes'). '/tpl_new_sidebox.php');
   //do some db query and other processing here

   $left_corner = false;
   $right_corner = false;
   $right_arrow = false;
   require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE,
   $current_page_base,'common') . '/' . $column_box_default);



[codesyntax lang=”php”]

  define('BOX_HEADING_NEW_SIDEBOX', 'Gallery');



[codesyntax lang=”php”]

 $content = <<< End_Of_Quote
  Enter your sidebox content here


zen cart — how to get the url of the current page

i want to set a anchor in all page.so when the user click on the anchor,it will bring user back to the head of the current page.i just don’t want to call too much javascript code.

[codesyntax lang=”php”]

<a href="#backhome">Back to top</a>


The code up there not work.As the browser will fix the anchor url  which cut the current url from last slash.for example

http://www.abcdomain.com/product-one_p_29.html   => http://www.abcdomain.com/#backhome

http://www.abcdomain.com/category1/product-one_p_29.html => http://www.abcdomain.com/category1/#backhome

$_SERVER[‘REQUEST_URI‘] stores the url from the root, see example below

http://www.abcdomain.com/product-one_p_29.html => product-one_p_29.html
http://www.abcdomain.com/category1/product-one_p_29.html  =>

so the anchor snippet code can be adapter to the following code

[codesyntax lang=”php”]

<a href="<?php echo $_SERVER['REQUEST_URI']?>#backhome">Back to top</a>




php — how to check if js enabled in the client

PHP is running in the server side,so it has no access to the client’s browser.how to check if the the javascript status of the client’s browser?Technically no way but we may get some way to work out.

setting cookies with JS and detecting them from PHP, see the example code below:

[codesyntax lang=”php”]

if($_SESSION['JSexe']){     //3rd check js
    if($_COOKIE['JS'])  setcookie('JS','JS',time()-1);//check on every page load
    else            header('Location: js.html');
}               //2nd so far it's been server-side scripting. Client-side scripting must be executed once to set second cookie.
                //Without JSexe, user with cookies and js enabled would be sent to js.html the first page load.
elseif($_COOKIE['PHP'])     $_SESSION['JSexe'] = true;
else{               //1st check cookies
    if($_GET['cookie']) header('Location: cookies.html');
                header('Location: '.$_SERVER['REQUEST_URI'].'?cookie=1');
<script type="text/javascript">document.cookie = 'JS=JS'</script>