Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Join Date
    Dec 2007
    Posts
    54
    Plugin Contributions
    0

    Default Top Categories list under Product list

    Hi!

    I am trying to add a top categories list (the same as it appears on main page centerb) under product listing.
    I believe it will make navigating my site much easier because I don't use sideboxes at all, so there isn't a categories list on any side.


    I have tried adding the following code just before the code for featured, specials, etc. centerboxes:

    1. added following code from tpl_index_categories.php to tpl_index_product_list.php
    PHP Code:
    <div class="centerColumn" id="indexCategories">
    <div id="indexCategoriesMainContent" class="content"><?php
    /**
     * require the html_define for the index/categories page
     */
      
    include($define_page);
    ?></div>

    <?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_WIDTHSUBCATEGORY_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');
      }
    ?>
    </div>
    <!-- EOF: Display grid of available sub-categories -->
    2. added following code I found on the forum to tpl_index_product_list.php
    PHP Code:
    <?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');
    ?>
    3. tried also with these two lines
    PHP Code:
    <?php require($template->get_template_dir('tpl_modules_category_row.php',DIR_WS_TEMPLATE$current_page_base,'templates'). '/tpl_modules_category_row.php'); ?>
    PHP Code:
    <?php require($template->get_template_dir('tpl_index_categories.php',DIR_WS_TEMPLATE$current_page_base,'templates'). '/tpl_index_categories.php'); ?>

    And neither works!
    The product listing looks and works normal, completely ignoring any of my attempts.

    I am sure there is a very simple solution to this issue, but I can't seem to find it.

    Can anyone help?

    Thanks!

  2. #2
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Top Categories list under Product list

    Is there a reason you don't want to use the categories-tabs menu bar in the header? You can even add a simple test to it to hide it on the homepage if you don't need it there. Seeing your site live will help us make appropriate suggestions.

  3. #3
    Join Date
    Dec 2007
    Posts
    54
    Plugin Contributions
    0

    Default Re: Top Categories list under Product list

    Quote Originally Posted by gjh42 View Post
    Is there a reason you don't want to use the categories-tabs menu bar in the header? You can even add a simple test to it to hide it on the homepage if you don't need it there. Seeing your site live will help us make appropriate suggestions.
    Yes, there are two! :)

    1. my main page top categories list is heavily modified and I would like to use it if it's possible
    2. categories-tabs don't fit into my current design. I could make it work but that would require a significant redesign. Simply adding the existing categories under the product list is much simpler and quicker (well, at least - should be).

    You can check out the website here: http://bit.ly/1dGPsur

    Thank your extremely fast reply!

  4. #4
    Join Date
    Dec 2007
    Posts
    54
    Plugin Contributions
    0

    Default Re: Top Categories list under Product list

    Quote Originally Posted by ivanc View Post
    Thank your extremely fast reply!
    Thank *you for* your extremely fast reply! :)

  5. #5
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Top Categories list under Product list

    You don't want this bit in your product listing page, as $define_page will not be set for a product page. The include may not cause an error, but it will not do anything you want.
    PHP Code:
    <div id="indexCategoriesMainContent" class="content"><?php
    /**
     * require the html_define for the index/categories page
     */
      
    include($define_page);
    ?></div>
    In what order did you add the code snippets to the file? The sql query must be run before output files are called, or there will be no content to output.

  6. #6
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Top Categories list under Product list

    Looking closer, you don't want any of your first block of code. The second block with the sql query will probably get the data (I haven't checked it thoroughly). You also don't want tpl_index_categories.php as that outputs a whole page content. You do want tpl_modules_category_row.php after the sql query is run and $categories is populated.

    You don't need
    $number_of_categories = $categories->RecordCount(); as a similar variable is set by category_row.php (which is called by tpl_modules_category_row.php).

  7. #7
    Join Date
    Dec 2007
    Posts
    54
    Plugin Contributions
    0

    Default Re: Top Categories list under Product list

    Sorry, didn't see your second post before replying, will check now!
    Last edited by ivanc; 24 Mar 2014 at 04:30 PM. Reason: Sorry, didn't see your second post before replying, will check now!

  8. #8
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Top Categories list under Product list

    If you are still not getting results, you might try adding debug code, say after
    PHP Code:
        $categories $db->Execute($categories_query); 
    like
    PHP Code:
    echo ' $categories populated: ' var_dump($categories); 

  9. #9
    Join Date
    Dec 2007
    Posts
    54
    Plugin Contributions
    0

    Default Re: Top Categories list under Product list

    No luck, anything I try is completely ignored.

    I am posting my complete tpl_index_product_list.php including the changes you suggested:

    PHP Code:
    <?php
    /**
     * Page Template
     *
     * Loaded by main_page=index<br />
     * Displays product-listing when a particular category/subcategory is selected for browsing
     *
     * @package templateSystem
     * @copyright Copyright 2003-2010 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_product_list.php 15589 2010-02-27 15:03:49Z ajeh $
     * modified 2012-06-26 by A. Sarfraz
     * modified 2012-09-22 & 2012-10-06 by Glenn Herbert (gjh42)
     */
    ?>
    <div class="centerColumn" id="indexProductList">

    <h1 id="productListHeading"><?php echo $breadcrumb->last(); ?></h1>

    <?php
    if (PRODUCT_LIST_CATEGORIES_IMAGE_STATUS == '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''CATEGORY_ICON_IMAGE_WIDTHCATEGORY_ICON_IMAGE_HEIGHT); ?></div>
    <?php
      
    }
    // categories_image
    ?>

    <?php
    // categories_description
        
    if ($current_categories_description != '') {
    ?>
    <div id="indexProductListCatDescription" class="content"><?php echo $current_categories_description;  ?></div>
    <?php // categories_description ?>

    <?php
      $check_for_alpha 
    $listing_sql;
      
    $check_for_alpha $db->Execute($check_for_alpha);

      if (
    $do_filter_list || ($check_for_alpha->RecordCount() > && PRODUCT_LIST_ALPHA_SORTER == 'true') || (defined('PRODUCT_LISTING_LAYOUT_STYLE_CUSTOMER') and PRODUCT_LISTING_LAYOUT_STYLE_CUSTOMER == '1')) {//form if list/grid enabled
      
    $form zen_draw_form('filter'zen_href_link(FILENAME_DEFAULT), 'get') . '<label class="inputLabel">' .TEXT_SHOW '</label>';
    ?>

    <?php
      
    echo $form;
      echo 
    zen_draw_hidden_field('main_page'FILENAME_DEFAULT);
      echo 
    zen_hide_session_id();
    ?>
    <?php
      
    // draw cPath if known
      
    if (!$getoption_set) {
        echo 
    zen_draw_hidden_field('cPath'$cPath);
      } else {
        
    // draw manufacturers_id
        
    echo zen_draw_hidden_field($get_option_variable$_GET[$get_option_variable]);
      }

      
    // draw music_genre_id
      
    if (isset($_GET['music_genre_id']) && $_GET['music_genre_id'] != '') echo zen_draw_hidden_field('music_genre_id'$_GET['music_genre_id']);

      
    // draw record_company_id
      
    if (isset($_GET['record_company_id']) && $_GET['record_company_id'] != '') echo zen_draw_hidden_field('record_company_id'$_GET['record_company_id']);

      
    // draw typefilter
      
    if (isset($_GET['typefilter']) && $_GET['typefilter'] != '') echo zen_draw_hidden_field('typefilter'$_GET['typefilter']);

      
    // draw manufacturers_id if not already done earlier
      
    if ($get_option_variable != 'manufacturers_id' && isset($_GET['manufacturers_id']) && $_GET['manufacturers_id'] > 0) {
        echo 
    zen_draw_hidden_field('manufacturers_id'$_GET['manufacturers_id']);
      }

      
    // draw sort
      
    echo zen_draw_hidden_field('sort'$_GET['sort']);

      
    // draw filter_id (ie: category/mfg depending on $options)
      
    if ($do_filter_list) {
        echo 
    zen_draw_pull_down_menu('filter_id'$options, (isset($_GET['filter_id']) ? $_GET['filter_id'] : ''), 'onchange="this.form.submit()"');
      }
      
      if (
    defined('PRODUCT_LISTING_LAYOUT_STYLE_CUSTOMER') and PRODUCT_LISTING_LAYOUT_STYLE_CUSTOMER == '1') {
        echo 
    '<div id="viewControl">' zen_draw_pull_down_menu('view', array(array('id'=>'rows','text'=>PRODUCT_LISTING_LAYOUT_ROWS),array('id'=>'columns','text'=>PRODUCT_LISTING_LAYOUT_COLUMNS)), (isset($_GET['view']) ? $_GET['view'] : (defined('PRODUCT_LISTING_LAYOUT_STYLE')? PRODUCT_LISTING_LAYOUT_STYLE'rows')), 'onchange="this.form.submit()"') . '</div>';  
      }
      
    // draw alpha sorter
      
    require(DIR_WS_MODULES zen_get_module_directory(FILENAME_PRODUCT_LISTING_ALPHA_SORTER));
    ?>
    </form>
    <?php
      
    }
    ?>
    <br class="clearBoth" />

    <?php
    /**
     * require the code for listing products
     */
     
    require($template->get_template_dir('tpl_modules_product_listing.php'DIR_WS_TEMPLATE$current_page_base,'templates'). '/' 'tpl_modules_product_listing.php');
    ?>


    <?php
    //// bof: categories error
    if ($error_categories==true) {
      
    // verify lost category and reset category
      
    $check_category $db->Execute("select categories_id from " TABLE_CATEGORIES " where categories_id='" $cPath "'");
      if (
    $check_category->RecordCount() == 0) {
        
    $new_products_category_id '0';
        
    $cPath'';
      }
    ?>

    <?php
    $show_display_category 
    $db->Execute(SQL_SHOW_PRODUCT_INFO_MISSING);

    while (!
    $show_display_category->EOF) {
    ?>

    <!-- INSERT CATEGORIES HERE TOP -->
    <?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);
        echo 
    ' $categories populated: ' var_dump($categories);  
       
     require(
    $template->get_template_dir('tpl_modules_category_row.php',DIR_WS_TEMPLATE$current_page_base,'templates'). '/tpl_modules_category_row.php'); 
    ?>
    <!-- INSERT CATEGORIES HERE BOTTOM -->

    <?php
      
    if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_MISSING_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_MISSING_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_MISSING_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_MISSING_UPCOMING') {
        include(
    DIR_WS_MODULES zen_get_module_directory(FILENAME_UPCOMING_PRODUCTS));
      }
    ?>
    <?php
      $show_display_category
    ->MoveNext();
    // !EOF
    ?>
    <?php 
    //// eof: categories error ?>

    <?php
    //// bof: categories
    $show_display_category $db->Execute(SQL_SHOW_PRODUCT_INFO_LISTING_BELOW);
    if (
    $error_categories == false and $show_display_category->RecordCount() > 0) {
    ?>

    <?php
      $show_display_category 
    $db->Execute(SQL_SHOW_PRODUCT_INFO_LISTING_BELOW);
      while (!
    $show_display_category->EOF) {
    ?>

    <?php
        
    if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_LISTING_BELOW_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_LISTING_BELOW_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_LISTING_BELOW_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_LISTING_BELOW_UPCOMING') {
          include(
    DIR_WS_MODULES zen_get_module_directory(FILENAME_UPCOMING_PRODUCTS));
        }
    ?>
    <?php
      $show_display_category
    ->MoveNext();
      } 
    // !EOF
    ?>

    <?php
    //// eof: categories
    ?>

    </div>
    Perhaps my positioning is wrong?

    ps. featured products on product listing will be turned off when (or IF) I get this working

  10. #10
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Top Categories list under Product list

    You have
    PHP Code:
    <?php
    $show_display_category 
    $db->Execute(SQL_SHOW_PRODUCT_INFO_MISSING);

    while (!
    $show_display_category->EOF) {
    ?>

    <!-- INSERT CATEGORIES HERE TOP -->
    Your new code is inside the while() loop, so will only be executed if there is anything in $show_display_category. Move your code either above or below that while() loop.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Rogue Categories list at top
    By cyberchute in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 20 Apr 2013, 04:22 AM
  2. Replies: 2
    Last Post: 30 Jul 2008, 08:35 AM
  3. Move manufactures list from sidebox to under top horizontal nav
    By phastings in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 30 Dec 2007, 12:59 PM
  4. Remove top Categories list.
    By markpr9 in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 18 Dec 2007, 04:39 PM
  5. Turning off horizontal categories list at top of content
    By multichild in forum Installing on a Windows Server
    Replies: 1
    Last Post: 21 Sep 2007, 04:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg