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 / Can't get Featured products to show on home page

Can't get Featured products to show on home page

Started by lidlchris on 31 Aug 2016, 8:32 PM · Views: 3,329

Results 1 to 11 of 11
31 Aug 2016, 8:32 PM
#1
lidlchris avatar

lidlchris

Zen Follower

Join Date:
Feb 2013
Posts:
345
Plugin Contributions:
0

Post #1 by lidlchris

I can't get the featured products to show up as the default on the home page at https://criticalsystemsincshop.com/index.html. The new products keeps showing up. I ordered the pages like this:

Show New Products on Main Page 3 Info
Show Featured Products on Main Page 1 Info
Show Special Products on Main Page 2 Info

and i changed the template file tpl_index_default.php to make the featured 'active' (which seems to work as it's highlighted). but still the new products show up in the content area.

31 Aug 2016, 9:27 PM
#2
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,915
Plugin Contributions:
24

Post #2 by dbltoe

Things like this should very seldom need file changes. Should all be controllable in the admin configuration menu. The first is at Maximum Values that determines how many to display on the home page. Of course Featured Listing is important to define what's in each featured listing. The actual turning on or off of the main page listing is in Configuration >> Index Listing.

Sometimes an odd item is also programmable from the edit layout button in Catalog >> Product Types. This does not effect the home page but is often helpful on product pages.

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

31 Aug 2016, 10:41 PM
#3
lidlchris avatar

lidlchris

Zen Follower

Join Date:
Feb 2013
Posts:
345
Plugin Contributions:
0

Post #3 by lidlchris

dbltoe:

Things like this should very seldom need file changes. Should all be controllable in the admin configuration menu. The first is at Maximum Values that determines how many to display on the home page. Of course Featured Listing is important to define what's in each featured listing. The actual turning on or off of the main page listing is in Configuration >> Index Listing.

Sometimes an odd item is also programmable from the edit layout button in Catalog >> Product Types. This does not effect the home page but is often helpful on product pages.

The first is at Maximum Values that determines how many to display on the home page.
Yes these seem to be correct.

Of course Featured Listing is important to define what's in each featured listing.
what do you mean by this?? i defined 2 products as 'featured' so i'm assuming they show up under 'featured', which they do if you click on the 'featured' tab.

The actual turning on or off of the main page listing is in Configuration >> Index Listing.
Yes these seem to be set ok. Attachment 16626

Sometimes an odd item is also programmable from the edit layout button in Catalog >> Product Types. This does not effect the home page but is often helpful on product pages.
Yes that doesn't come into play here..

The coding looks good in tpl_index_default:

<div id="moduleMenu-wrapper">
<?php
// bof module navigation
$show_display_nav = $db->Execute(SQL_SHOW_PRODUCT_INFO_MAIN);
if ($this_is_home_page) {
  echo '';
}
//echo '<div id="moduleMenu">';
while (!$show_display_nav->EOF) {
  switch ($show_display_nav->fields['configuration_key']) {
    case 'SHOW_PRODUCT_INFO_MAIN_FEATURED_PRODUCTS':
      echo '<span class="navOne moduleSpan active_tab"><a href="javascript:void(0)" rel="featuredProducts" class="navOne moduleBox active">Featured</a></span>';
    break;
    case 'SHOW_PRODUCT_INFO_MAIN_SPECIALS_PRODUCTS':
      echo '<span class="navThree moduleSpan"><a href="javascript:void(0)" rel="specialsDefault" class="navThree moduleBox">Specials</a></span>';
    break;
    case 'SHOW_PRODUCT_INFO_MAIN_NEW_PRODUCTS':
      echo '<span class="navTwo moduleSpan"><a href="javascript:void(0)" rel="whatsNew" class="navTwo moduleBox">New</a></span>';
    break;
  }
  $show_display_nav->MoveNext();
}
//echo '<span id="navFour" class="moduleSpan"><a href="javascript:void(0)" id="navFour" rel="viewAll" class="moduleBox">All</a></span>';

?>
<span><?php //echo '<a class="moduleBox" href="' . zen_href_link(FILNAME_COMPARE).'">Compare</a>'; ?></span>
<br class="clearBoth" />

<?php
//echo '</div>';
// eof module navigation

  $show_display_category = $db->Execute(SQL_SHOW_PRODUCT_INFO_MAIN);
  while (!$show_display_category->EOF) {
?>

<?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_MAIN_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_MAIN_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_MAIN_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_MAIN_UPCOMING') 
{ ?>
<?php
/**
 * display the Upcoming Products Center Box
 */
?>
<?php include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_UPCOMING_PRODUCTS)); ?><?php } ?>


<?php
  $show_display_category->MoveNext();
} // !EOF
?>
</div>
6 Sep 2016, 4:24 PM
#4
picandnix avatar

picandnix

Totally Zenned

Join Date:
Dec 2010
Location:
UK
Posts:
1,779
Plugin Contributions:
2

Post #4 by picandnix

As stated, no code should be touched to display featured products, it's all controlled via admin. However to rule out one potential, could you tell us exactly which template you are using?

Ah, I see ...##########...

6 Sep 2016, 4:38 PM
#5
lidlchris avatar

lidlchris

Zen Follower

Join Date:
Feb 2013
Posts:
345
Plugin Contributions:
0

Post #5 by lidlchris

picandnix:

As stated, no code should be touched to display featured products, it's all controlled via admin. However to rule out one potential, could you tell us exactly which template you are using?

Ah, I see ...##########...

yes it's the ########## template and yes i think i have all of the admin settings correct as 'featured' is highlighted on the home page yet 'new products' are displayed.. i've attached the code previously as i think it's a bug in the code.

6 Sep 2016, 6:32 PM
#6
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #6 by mc12345678

If it helps any, the mobile "version" of the site allows selection of each of the three tabs at the top, but when the page was processed through html validation there were 35 errors identified, some of which may play directly into the issue such as lists that are not properly "controlled". All that said, seems like because of the "obscuring" of the template name that the suggestion is to go back to the template author and ask them what the fix is. It would seem that it is probably a commercial template and as such should be commercially "repaired".

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

6 Sep 2016, 7:42 PM
#7
picandnix avatar

picandnix

Totally Zenned

Join Date:
Dec 2010
Location:
UK
Posts:
1,779
Plugin Contributions:
2

Post #7 by picandnix

Yes it's that template that looks really good (imo) but plays really bad unfortunately.

6 Sep 2016, 7:54 PM
#8
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #8 by mc12345678

To maybe explain, it's likely not specifically the section of code that was provided above, but how the entire page is put together. The links that are to be clicked on respond/change because of some variation of javascript. Javascript and other variations work off of what is existing on the page and process that information like a program. If the program has errors, then it can not function as desired.

Frequently if the page fails validation, then the associated javascript will not function or will only function up to a point. So, get the page to validate by hunting down the expected/required formatting and then likely the other options will work as expected.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

6 Sep 2016, 9:52 PM
#9
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Post #9 by carlwhat

wow; until ZC provides a template that makes EVERY store owner happy, store owners will procure outside templates based on design, functionality, etc.

i see no "bug" in this template that requires "repair".

the template's default content on the HOME page is new products. it is NOT the new products page; it is the home page. you can then change the content via clicking and javascript. there are no configuration tools to change this default. the template's home page is the home page.

if you want to change the default for the template to be featured products, you need to change the CSS. CSS is hard, but it is not impossible.

lidlchris, if you want the featured products to be the default on the home page (ie index.php?main_page=index), you need to change the CSS. specifically:

on line 1323 of includes/templates/XXXXXX/css/mj-template.css

change:

#featuredProducts

to

#whatsNew

on line 2358 of the same file change:

#whatsNew

to

#featuredProducts

please let us all know how it goes!

good luck.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

7 Sep 2016, 2:49 AM
#10
barco57 avatar

barco57

Totally Zenned

Join Date:
Apr 2006
Location:
West Salem, IL
Posts:
2,846
Plugin Contributions:
0

Post #10 by barco57

+1 for carlwhat's solution

Mike
AEIIA - Zen Cart Certified & PCI Compliant Hosting
The Zen Cart Forum...Better than a monitor covered with post-it notes!

7 Sep 2016, 4:48 PM
#11
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #11 by mc12345678

While the offered solution of changing the css will solve this issue for this one request, having had an opportunity to get to a computer the following is suggested to provide what looks like a more robust solution. So in following with the discussion of others that there should be no code changes needed to make whatever lowest, non-zero tab group be the default selected option (controlling the sort order by the admin settings), the template should do more to force the first tab to be the selected tab when the page is loaded. So in part I disagree that there is no "bug" with this template (even if the html validation issues previously referenced haven't yet affected the javascript/jquery).
‎
I did partially misunderstand one detail of the issue, thinking that selection of anything other than the new tab didn't work. ‎Instead the issue was that assigning a tab other than the new tab to be the default (first) tab did not force display of the associated content when the page was initially displayed.
‎
To resolve that issue regardless of the desired first tab (again as set in the admin), when the page loads, the javascript (or variation of) associated with showing the active tab and hiding the other tabs should be executed on the numerically (sorted order pretty much) first tab if one is displayed. The tabs are already presented in a sorted order based on the admin settings, so the issue is then to activate the first one.
‎
One way to accomplish this with regards to the above (even though one of the divs was commented out in the above provided code) is to add an on_load file such as:

includes/modules/pages/index/on_load_tabs.js
(or as necessary the name modified to be other than "tabs" such that it loads in the necessary sequence to support execution of the click operation)

if ($("#moduleMenu-wrapper").length){
  if ($("#moduleMenu-wrapper span").length) {

    var classList = $("#moduleMenu-wrapper span").first().attr("class").split(/[ \n\r\t\f]+/); //Get the class from the first span of the moduleMenu-wrapper and split it into an array such that can evaluate each element

    if (classList.length) { // If there is at least one element
      if ($("a").hasClass(classList[0])) { // If the "a" tag element has the class of the first element of the span (ie. navOne, navTwo, navThree, etc...)
        $(document).ready(function() { // Take action within this function
          $("a." + classList[0]).trigger("click"); // Activate the click of the "a" tag element having the above identified class
        });
      }
    }
  }
}

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...