Modify your Zen Cart

I installed Zen Cart on a client’s machine…

  1. installation was a breeze

  2. the problem is it is very easily ideifiable as a Zen Cart… which is bad for a professional site. Everything should look home-grown
  3. The client has an existing site which doesn’t really fit with the Zen Cart presentation style. So I have to do a little conversion
  4. There is basically NO DOCUMENTATION so I’m having to look through the source code to figure out how to implement these changes

Here’s my notes on making the switch!

Overview for every page

As is evident from looking at the URLs of any part of the catalog, the “main” page is just index.php, regardless of what the content of the page is. For any particular page it loads, it has a default file it uses for the entire site, which may be overridden by a locally defined file.

Most of these are PHP code only:

  1. includes/application_top.php – this location is one of the only file paths hard-coded into the PHP code. Its companion does NOT use the “includes” name directly but rather a constant define “DIR_WS_INCLUDES”
  2. includes/modules/pages/[PAGE_NAME]/header_php* – defines some of the product-specific queries and settings for variables defined in application_top.php. You can make other files which will get loaded too, if they start with the phrase header_php
  3. main_template_vars.php:

    Define Template Variables picked up from includes/templates/[NAME OF TEMPLATE]/common/main_template_vars.php unless a file exists in the includes/modules/pages/[PAGE_NAME]/ directory to overide. Allowing different pages to have different overall templates.

  4. tpl_main_page.php:

    Define the template that will govern the overall page layout, can be done on a page by page basis or using a default template. The default template installed will be a standard 3 column lauout. This template also loads the page body code from a page named in the variable $body_code.

    (This refers to includes/templates/template_default/common/tpl_main_page.php for the entire site or
    includes/templates/template_default/[PAGE_NAME]/tpl_main_page.php for a specific page )

    …anyway, that’s how it associates the “main_page” attribute with a PHP page in one of those two locations. That content page will determine the contents between the two columns and above the “center” elements such as “new products”.

  5. includes/application_bottom.php – Actually uses a constant define “DIR_WS_INCLUDES” so watch out!

The page ALSO has a main location-

  • includes/languages/english/[TEMPLATE_NAME]/[PAGE_NAME] – or more generally includes/languages/[LANGUAGE]/[TEMPLATE_NAME]/[PAGE_NAME] – defines:
    1. the navbar and heading titles
    2. THE CONTENT!!! Whew! At Last! it’s stored in the variable TEXT_INFORMATION

Including the Static Pages

  • In the demo store there are some mostly-static main content pages under “Information” and “More Information”. Focussing on “More Information.”
  • I have a includes/languages/english/[NEW_PAGE_NAME].php . My first inclination was to assume that this is where the bulk of the information for the page should live.
  • I see files for the "classic" template like languages/english/classic/[NEW_PAGE_NAME].php . I'm thinking this is for styling the same page in different formats for different template. Are these pages required? If I make a template called BLAH in includes/templates/BLAH do I absolutely need to make files for all my content pages in languages/english/BLAH/[NEW_PAGE_NAME].php ?
  • how about includes/modules/pages/[NEW_PAGE_NAME]? It looks like there is only a small file, header_php.php, there. Do I absolutely need something there? what is that area for, besides putting this small file there?
  • I also see a great deal of material in includes/templates/template_default/templates/tpl_[NEW_PAGE_NAME]_default.php. This looks to be the default templates for every module, and therefore every content page, so that I need not define a languages/english/BLAH/[NEW_PAGE_NAME].php for my BLAH template.

So, in summary:

  1. add includes/languages/english/[NEW_PAGE].php for your main content
  2. add includes/languages/english/[TEMPLATE]/[NEW_PAGE].php if you want your page content to be different in that particular template than the default you just defined
  3. add includes/templates/template_default/templates/tpl_[NEW_PAGE]_default.php for your template (not the content)
  4. add includes/modules/pages/[NEW_PAGE]/header_php.php, possibly for your variable settings

Top Header

  • The header is defined in includes/templates/template_default/common/tpl_header.php
  • Default has
    1. Home
    2. Log In/Out
    3. My Account
    4. Cart (if cart nonempty)
    5. Checkout (if cart nonempty)
    6. Logo banner
    7. Error Message (if any)
    8. Info Message (if any)

    These messages are defined in

  • so to get the “buy your candy today!” and countdown message we could:
    1. add another field to the top- might be a little busy!

  • Need to add top of logo as first element on left- others can slide to right?
  • Or, possibly have cart navigation etc BELOW the original banner art

Bottom Footer

  • includes/modules/footer.php defines a few variables…
  • …which are then displayed by includes/templates/template_default/common/tpl_footer.php
  • Default footer has
    1. Bottom Nav Bar with “Home”
    2. IP address of client ?!
    3. whatever was defined in footer.php, in our case the copyright notice
    4. the END OF THE BIG TABLE !!
    5. Advertising banners
    6. the parse time
  • We should probably put the bottom navigation links in here

Information Panels

Including the new pages:

  • include/filenames.php – defined FILENAME_[NEW_PAGE_NAME] for each page
  • include/languages/english.php – defined BOX_INFORMATION_[NEW_PAGE_NAME]
  • include/modules/sideboxes/more_information.php – added each page to the array using both the above variables

  • includes/modules/sideboxes/information.php
  • includes/modules/sideboxes/more_information.php is by default empty- make sure you add new items AFTER the closing brace of the conditional there!
  • both explicitly stack BOX_INFORMATION* variables together into an array and pass on to templates
  • BOX_INFORMATION* variables defined in both
    • includes/languages/english.php
    • admin/includes/languages/english.php
  • includes/templates/template_default/sideboxes/tpl_information.php – can also replace template_default with other template names
  • includes/templates/template_default/common/tpl_box_default.php – can also replace template_default with other template names
  • Must contain pages from old site:

    1. Custom info
    2. Visit us
    3. About the store

Other Notes

  • to change the titles of the pages:
    • admin/includes/languages/english.php
    • includes/languages/english.php
  • categories box for Zen Cart is at

    • template at includes/templates/template_default/sideboxes/tpl_categories.php
  • category_row.php seems to be only for index, used by
    however note that this file is only currently included in the template_default template
  • can you control which pages have which boxes?
    • individual boxes code is in includes/modules/sideboxes/*.php
    • the side boxes use constants defined in includes/languages/[LANGUAGE].php
    • the actual file which renders the boxes is ??
    • if we can find out which file includes the boxes, we will know how it determines
      which boxes run in a given page/template!
    • under which circumstances does
      includes/modules/sideboxes/template_default/[TEMPLATE_NAME]/??? run?

The Plan

Up to now our investigation has been totally speculative and non-invasive. Below we summarize all the changes and the notes:

  1. put all the application-specific PHP routines in a single file, and have it included at the end of application_top.php
    1. initially this will just define small functions which output store-specific strings
    2. Database accessing functions will initially output dummy text
    3. planned functions:
      1. getConnection() gets a vanilla database connection
      2. getSmallPromoText() generates the short text-only version of the current promotion
      3. makeHeaderPromo() incorporates that short text into header HTML
      4. getLargePromo() generates HTML for the larger version of the promotion
      5. getRandomSplash() returns HTML for a random product image, for use in a splash image
  2. copy template fileset; rename and modify color scheme and look and feel
    • for example, templates/blue_strip is the main area for “blue_strip”
    • see also languages/blue_strip for ???
    • see also modules/sideboxes/template_default/blue_strip for ???
  3. change the header:

    1. integrate logo top into left side of header navigation
    2. add call to action to navigation header (if there’s room!)
    3. modify banner design to match non-ZenCart version
  4. change the footer:

    1. eliminate old content
    2. make bottom navigation links to major site areas
    3. add contact info (phone numbers) and bottom stripe
  5. make templates for all static content – for each new mostly-static page create:
    1. includes/modules/pages/[NAME OF PAGE] to define the page-specific variables… which could be a 2-line header_php.php
    2. includes/languages/[LANGUAGE]/[TEMPLATE NAME]/[NAME OF PAGE] which has the actual text of the center pane
  6. include links to static pages in “information” panel
  7. not sure if changing tpl_main_page.php is even necessary!
  8. Make a combined “categories/search” sidebox
  9. Make a new “promotions” sidebox :
    1. uses routines defined in PHP included by application_top.php, above
    2. links to the seasonal items, or the custom items
    3. possibly just hack this as a 0% sale
    4. If there is room, make a text-only version which says the next major holiday and
      text incorporating the number of days remaining… this is to be used in the navigation header

  10. add images for products and categories; populate
    • images should be proportioned to scale down to 100×80
  11. deploy store

425 Monsters

At one point I was looking for (and finally found) a book of woodblock prints of Japanese monsters.

I have since gotten a great book that my friend Sandy brought from Japan: it’s called
(図説)日本妖快大全 (which MAY be read “[zusetsu] nippon youkai taizen” ??) which translates to (Illustrated) encyclopedia of japanese bewitching monsters I think. The book is by Shigeru Mizuki ( 水木 しげる).

The problem is I have no idea how to say the title, since there aren’t any furigana and my vocabulary isn’t very extensive, and my dictionaries don’t have any of these words in them. I had to piece it together by looking up the kanji, then finding all the readings for each, then looking up those phrases I built in my dictionary. Agh!

Searching for information, it’s the 妖快 part which is giving me problems. It seems to be associated with a lot of anime porn… maybe it means “fantastical” ?

Okay I did a little research on the author- he is pretty famous, having done:

  • Gegege no Kitaro – they made a Nintendo game out of this one, and a TV show. If you see a Japanese action figure of a boy with long hair combed over one eye, or a eyeball with legs (yes they are related!) then you have seen paraphernalia from this series.
  • Akuma-kun
  • Kappa no sanpei youkai daisakusen – I’ve never seen this one, but it has a kappa in it, so it must be good!

According to a post by “August Ragone”:

Shigeru Mizuki who lost his right arm in the Pacific War, and trained himself to draw with his left. He came to national attention in Japan in the mid-1960s with his striking and unusual style, and several of his manga were transformed into television seriess.

There seems to be a distinction between youkai, which are more like weird creatures like the Loch Ness Monster, from obake, which are more “abomination” type monsters, like undead things. I found an essay by Robert Jay Gould which was pretty informative.