Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Display categories top level on a custom page... How?

Display categories top level on a custom page... How?

Locked

Views: 6,404

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
28 Aug 2009, 12:47 AM
#1
edwardtilbury avatar

edwardtilbury

Zen Follower

Join Date:
Sep 2007
Posts:
169
Plugin Contributions:
0

Display categories top level on a custom page... How?

I need to have a custom page with the top level of categories because simple seo does not like

index.php?main_page=index&cPath=0

Instead of diplaying all my categories , I get kicked back to the homepage..

So what I'm trying to do is display all the categories on a custom page called, similar to ez pages...

Well I followed the how to make a custom page, that was easy, but trying to dissect the code and functions is tough.. All I need is my categories displayed for cPath=0 on a custom page..

Does anyone know which variables to change, do I have to include something like $_GET[cPath]=0; ? .. what's the correct way to fix this? I've seen some other people with similar problems but no answers.

Thanks, I'm looking for an answer, but just some suggestions would be a great help too!

29 Aug 2009, 12:35 AM
#2
bunyip avatar

bunyip

Totally Zenned

Join Date:
Sep 2004
Location:
Western Massachusetts
Posts:
2,361
Plugin Contributions:
1

Re: Display categories top level on a custom page... How?

You shouldn't need to any special coding to show the top-level categories on the main page - what's your setting for Admin > Configuration > Layout Settings > Categories - Always Show on Main Page?

29 Aug 2009, 12:58 AM
#3
edwardtilbury avatar

edwardtilbury

Zen Follower

Join Date:
Sep 2007
Posts:
169
Plugin Contributions:
0

Re: Display categories top level on a custom page... How?

actually its different, the categories on the main page work fine, but my main page is too cluttered, when the user clicks on "Products" he goes to this URL that shows all the different categories we have products for:

index.php?main_page=index&cPath=0

.. but you did give me an idea.. what's the PHP code that opens up the categories on the main page? I can probably take this and use it instead of the regular category code, since the index.php page doesn't request a _GET variable. :smile:

17 Sep 2009, 9:23 AM
#4
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Display categories top level on a custom page... How?

bunyip:

You shouldn't need to any special coding to show the top-level categories on the main page - what's your setting for Admin > Configuration > Layout Settings > Categories - Always Show on Main Page?That's very true.. However, if you are using the main page to create a "splash page", you probably would NOT display the categories there. You may want to create a separate "landing page" with just the top level categories.

And yes I could create a very separate page and link it to Zen.. Though I've done it once, I prefer not to create a "splash/opening page" outside of Zen Cart. (Makes things messy IMO) So I'll often use the main page to create a "splash/opening page" and the top level category to create a "landing page".

Like edwardtilbury, I have always used: http://www.yourdomain.com/index.php?main_page=index&cPath=0 to create this "landing page".

However both edwardtilbury and I have recently discovered that SEO apps will undo this. Some treat http://www.yourdomain.com/index.php?main_page=index&cPath=0 as being = to http://www.yourdomain.com/. Which leaves us to seek out another option to achieve the same end result..

So here's what I did:

I used the "ZenCart Define Page Generator" application
(http://www.zen-cart.com/index.php?main_page=product_contrib_info&products_id=804)

Using this tool, I created a defined page called "store_main"

These are the files the "ZenCart Define Page Generator" application generated:
includes/extra_datafiles/store_main_filenames.php
includes/languages/english/extra_definitions/custom_template/store_main.php
includes/languages/english/html_includes/define_store_main.php
includes/languages/english/html_includes/custom_template/define_store_main.php
includes/languages/english/custom_template/store_main.php
includes/modules/pages/store_main/header_php.php
includes/templates/custom_template/templates/tpl_store_main_default.php

I edited the "includes/templates/custom_template/templates/tpl_store_main_default.php" file and just below this code:<?php /** * require the html_define for the store_main page */ require($define_page); ?> </div>I added the following:```

<?php $cat_id=0; $categories_query = "SELECT c.categories_id, cd.categories_name, c.categories_image, c.parent_id FROM " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd WHERE c.parent_id = :parentID AND c.categories_id = cd.categories_id AND cd.language_id = :languagesID AND c.categories_status= '1' ORDER BY sort_order, cd.categories_name"; $categories_query = $db->bindVars($categories_query, ':parentID', $cat_id, 'integer'); $categories_query = $db->bindVars($categories_query, ':languagesID', $_SESSION['languages_id'], 'integer'); $categories = $db->Execute($categories_query); $number_of_categories = $categories->RecordCount(); require($template->get_template_dir('tpl_modules_category_row.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_category_row.php'); ?>

The only other tasks after this were making sure I changed the various menus (I'm using a dropdown menu and a site map in the footer..) and editing the breadcrumbs so that the "Home" link pointed to my new landing page.. Though I'm not using them for the site I am working on now, if I was using EZPages or the navMain links the "home" links would have to be edited as well to point to the new landing page..

Hope this all makes sense..

BTW, for anyone who stumbles across this who might ask why this can't be done with an EZ Page.. You can't add PHP code to an EZ Page.

See this in action:
<http://clients.overthehillweb.com/hairisle/> - Main Page
<http://clients.overthehillweb.com/hairisle/store_main> - New Landing Page

Add top level categories to another page
Insert top level categories