justin's zen cart schtick

How to Create a Static Page in Zen Cart

Say you want to create a new page called MyPage and link it from the information sidebox. Here's the seven step process to do that.
  1. Tell Zen Cart what new files/folders it should be looking for. In "includes/extra_datafiles/", create a file named "mypage_filenames.php" that looks like: <?php define('FILENAME_MYPAGE', 'mypage'); ?>
  2. Now we create the actual content. Make a file in "includes/languages/english/mytemplate/" called "mypage.php". In it you can define all of the normal content definitions. It normally looks something like: <?php define('NAVBAR_TITLE', 'This is mypages breadcrumb and title'); define('HEADING_TITLE', 'This is mypages heading!'); define('TEXT_INFORMATION', 'Here is where mypages actual content goes!'); ?>
  3. Create a new folder in "includes/modules/pages/" with the name you defined above in step one, so in our case it would be called "mypage".
  4. In your new folder create any files that you want executed, this includes any javascript, fancy php code, etc. However there must a file called "header_php.php" that contains the following: <?php require(DIR_WS_MODULES . 'require_languages.php'); $breadcrumb->add(NAVBAR_TITLE); ?>
  5. Now for the layout. Create the template file in the folder "includes/templates/mytemplate/templates/". You want it to be called "tpl_mypage_default.php". The standard layout is something like: <table width="100%" border="0" cellspacing="2" cellpadding="2"> <tr><td class="breadCrumb"> <?= $breadcrumb->trail(BREAD_CRUMBS_SEPARATOR); ?> </td></tr> <tr><td class="pageHeading" align="center"> <h1><?= HEADING_TITLE; ?></h1> </td></tr> <tr><td class="main"> <?= TEXT_INFORMATION; ?> </td></tr> <tr><td class="main"> <?= zen_back_link() . zen_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?> </td></tr> </table>
  6. Define the menu title. Open "includes/languages/mytemplate/english.php" (if it doesn't already exist, copy over the entire base file from "includes/languages/english.php" and modify that) and add a line like this: define('BOX_INFORMATION_MYPAGE', 'Visit MyPage!');
  7. Add it to the information sidebox in "includes/modules/sideboxes/mytemplate/more_information.php" by adding the line near the top: $more_information[] = '<a href="' . zen_href_link(FILENAME_MYPAGE) . '">' . BOX_INFORMATION_MYPAGE . '</a>';
And you're done!

lifefeed@gmail.com    »«    more zencart goodness    »«    home