HowTo:Add a static page

From ZenMagick Wiki

Jump to: navigation, search

Contents

Define Pages

Introduction

Define pages are zen-carts first attempt of being a CMS.

The admin interface contains the Define Pages Editor. It allows to edit the content area of a predefined set of pages. Examples are the Terms & Conditions or Contact Us pages.

The content is stored in flat files with support for multiple languages.

Unfortunately, it's not possible to add new define pages. One reason for that is, that each define page requires its own page handler (that is the code under includes/modules/pages/xxx/ with xxx being the page name).

To get around this limit and make it easier to add new define pages, ZenMagick adds the concept of static pages. The basic idea is that all define pages share a single page handler (or controller) to make it possible to add new define pages by just creating a new file under includes/languages/english/html_includes (or any other language).

To make this possible it is required to add the page name in the request (similar to ezpages). A typical URL would look like this:

http://localhost/index.php?main_page=static&cat=shippinginfo

The page controller is static and the actual page is specified in the cat parameter. ZenMagick comes with a handy function to make it easy to create those URLs in your template. Example (Terms & Conditions URL):

<a href="<?php $net->staticPage("conditions") ?>"><?php zm_l10n("Conditions") ?></a>

About Us Example

Using zen-cart

  1. Create the new define page file
    Create the file define_about_us.php in the includes/languages/english/html_includes folder.
  2. Edit
    Once the file exists it will show in the define page editor and can be edited like any other define page.
  3. Done
    Yep, that’s it!

The new static page is now accessible at the URL: http://[yourhost]/[pathtostore]/index.php?main_page=static&cat=about_us.

If you have pretty links enabled, the URL is: http://[yourhost]/[pathtostore]/static/about_us.

To consider are the crumbtrail and page title. Since there is only the file to work with, the page title and crumbtrail are derived from the filename. The rules to build the crubtrail and title is:

  1. Strip the define_ prefix and .php suffix from the filename
  2. Replace _ with space ‘ ‘
  3. Capitalize words

Following this rule, the new About Us page will have a page title of (surprise!) About Us and a crumbtrail of Home :: About Us.

Using ZenMagick's Static Page Editor

As of version 0.9.0 the default for define/static page handling is to expect the files inside the theme, rather than having them in zen-cart's lanuguage folder. You can use the new Static Page Editor from the admin interface (ZenMagick -> Static Page Editor) to create or edit static pages. There are no manual steps involved! If you are migration from a previous version and prefer to keep using the ttraditional zen-cart define_ files, there is a setting isZMDefinePages that can be used to configure this behaviour.

Static or not?

In contrast to zen-cart, ZenMagick allows PHP in define pages. That means that it is possible to use all of ZenMagick’s link functions rather than hardcoding all URL’s into your define pages. (You could even display product information - even though strictly speaking that wouldn’t be static any more ;)

EZPages

Personal tools