Archive for August, 2008

Using Zen Cart’s cPath System for Style Changes

Tuesday, August 26th, 2008

You probably already know that you can style certain category links differently based on the cPath. If not take a look at the notes in the file includes/templates/template_default/sideboxes/tpl_categories.php.

Using that same method, you can style the header, footer, and other parts of your site depending on the current cPath.

For example, let’s say you have a category on your web site that lists children’s decor. You want this area to have a more playful feel with a polka dot background for the header area. The category path is 5.

1. Open includes/templates/template_default/common/tpl_header.php

2. Right before the <div id=”headerWrapper”> type:

<?php
if ((int)$cPath == 5) {

<div id =”headerWrapperChildrens”>

the rest of the code here

</div>

} else {

<div id=”headerWrapper”>

the rest of the code here

</div>

}

3. Save the file and upload it to includes/templates/YOUR_CUSTOM_TEMPLATE/common/

4. Open your stylesheet.css file and define the style for #headerWrapperChildrens

Of course, this approach can be taken with many sections of your web site, the possibilities are up to you!

Where to Buy Contribution for Zen Cart

Monday, August 18th, 2008

My first official Zen Cart contribution, Where to Buy, is now available at Zen Cart. It is a module that allows store owners who sell their items at brick and mortar stores to enter store information via the Zen Cart admin panel. The information is displayed on the web site grouped by state in a table format. The table is given a css class so that it is easily styled.

See a live demo at: Luv2Lounge.com

Download the contribution here.

Using PHP str_ireplace() Function to Help with Zen Cart SEO

Friday, August 15th, 2008

This Zen Cart SEO tip is very esoteric, I’ve only used it once but with great results.By using php’s str_ireplace() function, you are able to name your categories with SEO in mind.

Background: Let’s say you sell everything red; red dresses, red hats, red shoes and so on. Your store is even named The Red Store. When setting up your categories you create Red Hats, Red Dresses, etc. You have the SEO mod installed and your url reads “red-dresses-c-1.html” , so far so good. But now you go to the front of your site and you just don’t like the way the category names look…. do customers really need to see “Red” before every category name?
Use: In my application, the web site is using category tabs across the top of the header and changes will relate to that set up but with a bit of thought you can use this tip no matter which category option you are using.

Download includes/modules/categories_tabs.php at the bottom of the file look for:

// create link to top level category

$links_list[] = ‘<a class=”‘ . $new_style . ‘” href=”‘ . zen_href_link(FILENAME_DEFAULT, ‘cPath=’ . (int)$categories_tab->fields['categories_id']) . ‘”>’ . $categories_tab_current . ‘</a> ‘;

$categories_tab->MoveNext();

And replace with:

// create link to top level category

$links_list[] = ‘<a class=”‘ . $new_style . ‘” href=”‘ . zen_href_link(FILENAME_DEFAULT, ‘cPath=’ . (int)$categories_tab->fields['categories_id']) . ‘”>’ . str_ireplace(”RED”,”",”$categories_tab_current”) . ‘</a> ‘;

$categories_tab->MoveNext();


Upload your edited file to includes/modules/yourCustomTemplate/

Go to your web site to see your changes. The category names are now just dresses, hats, shoes etc but the url, breadcrumb and headline tags have the complete category name. I would love to hear about how you’ve used this tip!