Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / Customizing the Look of Your Shop / Templates, Stylesheets, Page Layout / Category images at top of main page instead of bottom?

Category images at top of main page instead of bottom?

Locked
This thread is locked. New replies are disabled.
24 May 2007, 7:13 AM
#1
xscd avatar

xscd

New Zenner

Join Date:
May 2007
Posts:
10
Plugin Contributions:
0

Post #1 by xscd

Hello all-- I have my categories set to always display on the main page. However, I would like the category images/icons to be displayed above the main text of the page rather than beneath it. Would it be possible to edit a template to achieve this effect? If so, which template controls this aspect of the layout of the main page (what is its name and where is it located)?

Thank you. I'm enjoying learning Zen Cart, and the new book, "e-Start your Web Store with Zen Cart," is very nice and helpful.
:smile:

Steve

24 May 2007, 5:10 PM
#2
xscd avatar

xscd

New Zenner

Join Date:
May 2007
Posts:
10
Plugin Contributions:
0

Post #2 by xscd

To clarify, what I'm trying to do is to cause the HTML code that "Configuration -> Layout Settings -> Categories - Always Show on Main Page" (= true) produces to appear above the "Define Page" text instead of below that text, on the main page.

In other words, I'm trying to locate (find the name of) the file or files I would need to edit in order to change the logic and the order in which the XHTML code appears in the final constructed webpage for the main (first) page of the website.

I hope that makes sense. :blush:

29 May 2007, 6:55 PM
#3
canopy avatar

canopy

Totally Zenned

Join Date:
Oct 2006
Posts:
625
Plugin Contributions:
0

Post #3 by canopy

Try this: Use the Override System to edit the file includes/templates/template_default/templates/tpl_index_default.php.

Shift this section of the code according to your preference.

<?php if (DEFINE_MAIN_PAGE_STATUS >= 1 and DEFINE_MAIN_PAGE_STATUS <= 2) { ?>
<?php
/**
 * get the Define Main Page Text
 */
?>
<div id="indexDefaultMainContent" class="content"><?php require($define_page); ?></div>
<?php } ?>

Goh Koon Hoek, author of "e-Start Your Web Store with Zen Cart".
Printed book: www.lulu.com/content/10576284
Electronic book and Errata: www.cucumbermedia.com/store

29 May 2007, 7:11 PM
#4
canopy avatar

canopy

Totally Zenned

Join Date:
Oct 2006
Posts:
625
Plugin Contributions:
0

Post #4 by canopy

To add to my previous post:

If Categories - Always Show on Main Page = 0, edit the file "tpl_index_default.php"

If Categories - Always Show on Main Page = 1, edit the file "tpl_index_categories.php"

Goh Koon Hoek, author of "e-Start Your Web Store with Zen Cart".
Printed book: www.lulu.com/content/10576284
Electronic book and Errata: www.cucumbermedia.com/store

30 May 2007, 4:45 AM
#5
xscd avatar

xscd

New Zenner

Join Date:
May 2007
Posts:
10
Plugin Contributions:
0

Post #5 by xscd

Thank you very much for your reply, and than you so much for writing your wonderful guide to (and explanation of) Zen Cart and its configuration details, "e-Start your Web Store with Zen Cart." My copy has helped me greatly to understand Zen Cart and to prioritize the tasks involved in setting up a web store by following the same order as is presented in the book, of familiarizing onself with and configuring Zen Cart .
:smile:

25 Jul 2009, 5:42 PM
#6
creamcrackers avatar

creamcrackers

Zen Follower

Join Date:
May 2009
Posts:
228
Plugin Contributions:
1

Post #6 by creamcrackers

I am having problems with that

When i move the code.. i end up with the page text on the page TWICE.

I can move the code to the very bottom of the page (under where i am displaying featured products on the index pageI cant seem to get it to work in this order

  1. Categories
  2. Page Text
  3. Featured Products

Any ideas thanks?

25 Jul 2009, 7:05 PM
#7
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Post #7 by gjh42

You need to keep the moved code out of the centerbox loop. In tpl_index_categories.php about line 79,

<!-- EOF: Display grid of available sub-categories -->
<?php
$show_display_category = $db->Execute(SQL_SHOW_PRODUCT_INFO_CATEGORY);
//put the require here
while (!$show_display_category->EOF) {
1 Aug 2009, 5:32 PM
#8
creamcrackers avatar

creamcrackers

Zen Follower

Join Date:
May 2009
Posts:
228
Plugin Contributions:
1

Post #8 by creamcrackers

Hi

I do appreciate your reply.. however i cant get it to work

I did this

<!-- EOF: Display grid of available sub-categories --> <?php $show_display_category = $db->Execute(SQL_SHOW_PRODUCT_INFO_CATEGORY); <?php /** * require the html_define for the index/categories page */ include($define_page); ?>

while (!$show_display_category->EOF) {
// // echo 'I found ' . zen_get_module_directory(FILENAME_UPCOMING_PRODUCTS);

I did this in the tpl_index_categories.php

Now i am getting a blank page

I dont understand this wasted 2 days on it

I cant understand why they decided to display the categories below the page text... surely you want to categories at TOP of the page

1 Aug 2009, 5:48 PM
#9
creamcrackers avatar

creamcrackers

Zen Follower

Join Date:
May 2009
Posts:
228
Plugin Contributions:
1

Post #9 by creamcrackers

Ok

Forget all that, ive fixed it. Here is the code for tpl_index_categories.php if you want the categories to display at the top of the main page when Categories - Always Show on Main Page is set to "1" (in layout settings)

<?php /** * Page Template * * Loaded by main_page=index<br /> * Displays category/sub-category listing<br /> * Uses tpl_index_category_row.php to render individual items * * @package templateSystem * @copyright Copyright 2003-2006 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license <http://www.zen-cart.com/license/2_0.txt> GNU Public License V2.0 * @version $Id: tpl_index_categories.php 4678 2006-10-05 21:02:50Z ajeh $ */ ?> <div class="centerColumn" id="indexCategories"> <?php if ($show_welcome == true) { ?> <h1 id="indexCategoriesHeading"><?php echo HEADING_TITLE; ?></h1> <?php if (SHOW_CUSTOMER_GREETING == 1) { ?> <h2 class="greeting"><?php echo zen_customer_greeting(); ?></h2> <?php } ?> <!-- deprecated - to use - uncomment <?php if (TEXT_MAIN) { ?> <div id="" class="content"><?php echo TEXT_MAIN; ?></div> <?php } ?>--> <!-- deprecated - to use - uncomment <?php if (TEXT_INFORMATION) { ?> <div id="" class="content"><?php echo TEXT_INFORMATION; ?></div> <?php } ?>--> <?php } else { ?> <h1 id="indexCategoriesHeading"><?php echo $breadcrumb->last(); ?></h1> <?php } ?> <?php if (PRODUCT_LIST_CATEGORIES_IMAGE_STATUS_TOP == 'true') { // categories_image if ($categories_image = zen_get_categories_image($current_category_id)) { ?> <div id="categoryImgListing" class="categoryImg"><?php echo zen_image(DIR_WS_IMAGES . $categories_image, '', SUBCATEGORY_IMAGE_TOP_WIDTH, SUBCATEGORY_IMAGE_TOP_HEIGHT); ?></div> <?php } } // categories_image ?> <?php // categories_description if ($current_categories_description != '') { ?> <div id="categoryDescription" class="catDescContent"><?php echo $current_categories_description; ?></div> <?php } // categories_description ?> <!-- BOF: Display grid of available sub-categories, if any --> <?php if (PRODUCT_LIST_CATEGORY_ROW_STATUS == 0) { // do nothing } else { // display subcategories /** * require the code to display the sub-categories-grid, if any exist */ require($template->get_template_dir('tpl_modules_category_row.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_category_row.php'); } ?> <!-- EOF: Display grid of available sub-categories --> <?php $show_display_category = $db->Execute(SQL_SHOW_PRODUCT_INFO_CATEGORY); include($define_page); while (!$show_display_category->EOF) { // // echo 'I found ' . zen_get_module_directory(FILENAME_UPCOMING_PRODUCTS);

?>

<?php if (DEFINE_MAIN_PAGE_STATUS >= 1 and DEFINE_MAIN_PAGE_STATUS <= 2) { ?> <div id="indexCategoriesMainContent" class="content"></div> <?php } ?> <?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_CATEGORY_FEATURED_PRODUCTS') { ?> <?php /** * display the Featured Products Center Box */ ?> <?php require($template->get_template_dir('tpl_modules_featured_products.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_featured_products.php'); ?> <?php } ?> <?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_CATEGORY_SPECIALS_PRODUCTS') { ?> <?php /** * display the Special Products Center Box */ ?> <?php require($template->get_template_dir('tpl_modules_specials_default.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_specials_default.php'); ?> <?php } ?> <?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_CATEGORY_NEW_PRODUCTS') { ?> <?php /** * display the New Products Center Box */ ?> <?php require($template->get_template_dir('tpl_modules_whats_new.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_whats_new.php'); ?> <?php } ?> <?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_CATEGORY_UPCOMING') { ?> <?php include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_UPCOMING_PRODUCTS)); ?><?php } ?> <?php $show_display_category->MoveNext(); } // !EOF ?> </div>
11 Aug 2009, 1:54 AM
#10
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Post #10 by gjh42

I did this

<!-- EOF: Display grid of available sub-categories --> <?php $show_display_category = $db->Execute(SQL_SHOW_PRODUCT_INFO_CATEGORY); <?php /** * require the html_define for the index/categories page */ include($define_page); ?>

while (!$show_display_category->EOF) {
// // echo 'I found ' . zen_get_module_directory(FILENAME_UPCOMING_PRODUCTS);

I did this in the tpl_index_categories.php

Now i am getting a blank pagePresumably you found these (red) extra bits of code in your first modification version, which would cause problems.> <!-- EOF: Display grid of available sub-categories -->

<?php $show_display_category = $db->Execute(SQL_SHOW_PRODUCT_INFO_CATEGORY); include($define_page); while (!$show_display_category->EOF) {
26 Aug 2009, 12:36 PM
#11
sac4 avatar

sac4

New Zenner

Join Date:
Aug 2009
Posts:
8
Plugin Contributions:
0

Post #11 by sac4

I would like to have my categories appearing above my text on the main page too and have tried following the instructions without success. I either get a blank page or it makes no change at all.

This is the code

<?php if (DEFINE_MAIN_PAGE_STATUS >= 1 and DEFINE_MAIN_PAGE_STATUS <= 2) { ?> <div id="indexCategoriesMainContent" class="content"><?php /** * require the html_define for the index/categories page */ include($define_page); ?></div> <?php } ?> <?php } else { ?> <h1 id="indexCategoriesHeading"><?php echo $breadcrumb->last(); ?></h1> <?php } ?>

Can you please tell me what I need to do?

Also is it possible to change the column layout for the categories on the home page? At present they are showing in columns of 3 and I would like to change it to 4.

Thank you

28 Aug 2009, 9:06 AM
#12
sac4 avatar

sac4

New Zenner

Join Date:
Aug 2009
Posts:
8
Plugin Contributions:
0

Post #12 by sac4

It's me again

I still can't get this to work. I've got the code exactly (I think) as in post #9 but now my text on the main page is appearing on every page.

I also noted that the code referred to in post#8 require the html_define for the index/categories page no longer appears in the code on post#9

Can someone please help me with this?

Thank you

28 Aug 2009, 1:11 PM
#13
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Post #13 by gjh42

In tpl_index_categories.php, move this section from line 34:```php

<?php if (DEFINE_MAIN_PAGE_STATUS >= 1 and DEFINE_MAIN_PAGE_STATUS <= 2) { ?> <div id="indexCategoriesMainContent" class="content"><?php /** * require the html_define for the index/categories page */ include($define_page); ?></div> <?php } ?> ```to just after line 76:```php <!-- EOF: Display grid of available sub-categories [this is line 76]--> <?php $show_display_category = $db->Execute(SQL_SHOW_PRODUCT_INFO_CATEGORY);

while (!$show_display_category->EOF) {
to get:php

<!-- EOF: Display grid of available sub-categories --> <?php if (DEFINE_MAIN_PAGE_STATUS >= 1 and DEFINE_MAIN_PAGE_STATUS <= 2) { ?> <div id="indexCategoriesMainContent" class="content"><?php /** * require the html_define for the index/categories page */ include($define_page); ?></div> <?php } ?> <?php $show_display_category = $db->Execute(SQL_SHOW_PRODUCT_INFO_CATEGORY); while (!$show_display_category->EOF) { ```
28 Aug 2009, 2:11 PM
#14
sac4 avatar

sac4

New Zenner

Join Date:
Aug 2009
Posts:
8
Plugin Contributions:
0

Post #14 by sac4

Thank you for your reply Glenn

but the text on the main page is still appearing on every page.

Is this something that I have done (somewhere) or is this an issue with my template?

Here's my work in progress...

http://silvaroma.com/jewellery-c-35.html

29 Aug 2009, 6:06 AM
#15
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Post #15 by gjh42

My reply was to your previous post... I didn't see the second one (bleary morning eyes? or a stale window left open overnight?)

Anyway, the original code should check for being home page; maybe moving the section puts the output outside the area controlled by the check. Adding a check for

if ($this_is_home_page){

wrapped around the define page output will take care of it.

29 Aug 2009, 12:29 PM
#16
sac4 avatar

sac4

New Zenner

Join Date:
Aug 2009
Posts:
8
Plugin Contributions:
0

Post #16 by sac4

Sorry Glenn, I'm not sure exactly what you mean

I've made a number of attempts at adding this code in various different places but cannot get it to work.

Can you please tell me where this code needs to go?

Thank you for your time.

29 Aug 2009, 3:39 PM
#17
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Post #17 by gjh42

Integrate the check into the existing if statement:```php

<!-- EOF: Display grid of available sub-categories --> <?php if (DEFINE_MAIN_PAGE_STATUS >= 1 and DEFINE_MAIN_PAGE_STATUS <= 2 and $this_is_home_page) { ?> <div id="indexCategoriesMainContent" class="content"><?php /** * require the html_define for the index/categories page */ include($define_page); ?></div> <?php }?> <?php $show_display_category = $db->Execute(SQL_SHOW_PRODUCT_INFO_CATEGORY); while (!$show_display_category->EOF) { ```
29 Aug 2009, 6:04 PM
#18
sac4 avatar

sac4

New Zenner

Join Date:
Aug 2009
Posts:
8
Plugin Contributions:
0

Post #18 by sac4

:clap::clap:

Yes it's worked. :D

I was keeping the code separate. I nearly got there a couple of times but wouldn't have thought to remove that first bracket. I did add an 'and' at one point but left the 'if' in place.

Thank you so much for your patience.

1 Jul 2010, 2:21 PM
#19
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

Post #19 by dgent

Do you have any idea how to move the categories icons into the header file, so all the categories images are permanently at the top of the page much like a menu?

Ive tried copying sections of categories code from all the files, and either end up with blank pages, or not making any difference.

16 Oct 2010, 8:00 AM
#20
andycz avatar

andycz

New Zenner

Join Date:
Mar 2009
Location:
Czech republic
Posts:
10
Plugin Contributions:
0

Post #20 by andycz

Any ideas how to make main page not loading while ckick on category, see this thread?