Trouble with Displaying Category with Define Main Page
So I want to display a category on the main page along with the defined main page.
I have no problem with it when displaying the Top category, but when displaying a subcategory, the define main page elements aren't shown.
Is there a workaround for this?
My Current Configurations:
Configuration > Layout Settings
Categories - Always Show on Main Page: 1
Main Page - Opens With Category: 9
Categories - Always Open to Show Subcategories: 1
Re: Trouble with Displaying Category with Define Main Page
If I read that right you want define_page content on the product listings. The stock wording is a bit misleading. The main page is only one page - the index - home - landing page. There's no code present to call the $define_page on other pages as you navigate the various categories.
This tpl_index_default.php code would need to be added to the tpl_index_product_list.php...
<?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 } ?>
To control display of your preferred define_page you could change the switch DEFINE_MAIN_PAGE_STATUS to any other DEFINE_YOUR_PAGE_STATUS.
This would allow the original Zen Cart switches to control ALL occurrences of a define page. If that's the case I've found it very handy to add alternate switch positions to the originals like this:
Twitch - Categories - Always Show on Main Page
Always Show Categories on Main Page
0 = OFF Show Only Define Page
1 = Show Define Page - Categories
2 = Show Define Page - IndexBanner
3 = Show IndexBanner - Define Page
4 = Show IndexBanner - Define Page - Categories
Default category can be set to Top Level or a Specific Top Level
That assists with 'seeing' the matrix having various intertwined display elements and controls and 'knowing' what each one is for - and what it will do.
In my example ^ I have dedicated a banner for use on the index page only, then allowed various display orientations with one master switch that includes the original position and function for upgrade compatibility.
Re: Trouble with Displaying Category with Define Main Page
Hi Twitchtoo,
Thank you for the help and advice! This worked perfectly and did exactly what I was asking for.
I'll admit I'm not all too familiar with PHP, but this explination helped. I think I'll stick with manually changing the parameters as I need it.
Re: Trouble with Displaying Category with Define Main Page
Actually coming back to this since there was a slight problem.
While Twitchtoo's solution was helpful and actually worked, the code to display the define_main_page on tpl_index_product_list allowed for define_main_page to be displayed on all product listing pages. Category pages were not affected. So I decided to try to look for another possible solution and found this thread: https://www.zen-cart.com/showthread.php?138175-Banners-only-on-main-page
Thank you Ajeh for the guidance and code. Below is the detail of my process for those looking to do the same.
In order to get the results I wanted without the define_main_page showing up on my product listing pages, I had to move my define_main_page content into a banner and set that banner to show up at the position I wanted (in this case, top position 3)
I copied the tpl_main_page file from the default template files into my shop's template files and fixed this code:
Code:
<?php
if (SHOW_BANNERS_GROUP_SET3 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET3)) {
if ($banner->RecordCount() > 0) {
?>
<div id="bannerThree" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
}
}
?>
Into this:
Code:
<?php
if ($this_is_home_page && (SHOW_BANNERS_GROUP_SET3 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET3))) {
if ($banner->RecordCount() > 0) {
?>
<div id="bannerThree" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
}
}
?>
This changes this specific banner position and makes it so that it's only visible on the home page of your website and no where else. I can imagine this being useful in other functions as well.