Page 2 of 7 FirstFirst 1234 ... LastLast
Results 11 to 20 of 70
  1. #11
    Join Date
    Nov 2005
    Posts
    101
    Plugin Contributions
    0

    Default Re: Parent Categories Separated In 3 sideboxes

    thank you so much i appreciate all your help. ok i have been playing around with this for a while now and i just keep getting parse errors, maybe im placing the code in the wrong area, im going to attach the tpl_catagories.php file, if you dont mind could you just show me where i should be adding this. im 90% sure i understood what you said*L*. but as always getting it to work proves difficult.

    here is my original file

    Code:
    <?php
    /**
     * Side Box Template
     *
     * @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_categories.php 4162 2006-08-17 03:55:02Z ajeh $
     */
      $content = "";
      
      $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">' . "\n";
      for ($i=0;$i<sizeof($box_categories_array);$i++) {
        switch(true) {
    // to make a specific category stand out define a new class in the stylesheet example: A.category-holiday
    // uncomment the select below and set the cPath=3 to the cPath= your_categories_id
    // many variations of this can be done
    //      case ($box_categories_array[$i]['path'] == 'cPath=3'):
    //        $new_style = 'category-holiday';
    //        break;
          case ($box_categories_array[$i]['top'] == 'true'):
            $new_style = 'category-top';
            break;
          case ($box_categories_array[$i]['has_sub_cat']):
            $new_style = 'category-subs';
            break;
          default:
            $new_style = 'category-products';
          }
         if (zen_get_product_types_to_category($box_categories_array[$i]['path']) == 3 or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1)) {
            // skip if this is for the document box (==3)
          } else {
          $content .= '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
    
          if ($box_categories_array[$i]['current']) {
            if ($box_categories_array[$i]['has_sub_cat']) {
              $content .= '<span class="category-subs-parent">' . $box_categories_array[$i]['name'] . '</span>';
            } else {
              $content .= '<span class="category-subs-selected">' . $box_categories_array[$i]['name'] . '</span>';
            }
          } else {
            $content .= $box_categories_array[$i]['name'];
          }
    
          if ($box_categories_array[$i]['has_sub_cat']) {
            $content .= CATEGORIES_SEPARATOR;
          }
          $content .= '</a>';
    
          if (SHOW_COUNTS == 'true') {
            if ((CATEGORIES_COUNT_ZERO == '1' and $box_categories_array[$i]['count'] == 0) or $box_categories_array[$i]['count'] >= 1) {
              $content .= CATEGORIES_COUNT_PREFIX . $box_categories_array[$i]['count'] . CATEGORIES_COUNT_SUFFIX;
            }
          }
    
          $content .= '<br />' . "\n";
        }
      }
    
      if (SHOW_CATEGORIES_BOX_SPECIALS == 'true' or SHOW_CATEGORIES_BOX_PRODUCTS_NEW == 'true' or SHOW_CATEGORIES_BOX_FEATURED_PRODUCTS == 'true' or SHOW_CATEGORIES_BOX_PRODUCTS_ALL == 'true') {
    // display a separator between categories and links
        if (SHOW_CATEGORIES_SEPARATOR_LINK == '1') {
          $content .= '<hr id="catBoxDivider" />' . "\n";
        }
        if (SHOW_CATEGORIES_BOX_SPECIALS == 'true') {
          $show_this = $db->Execute("select s.products_id from " . TABLE_SPECIALS . " s where s.status= 1 limit 1");
          if ($show_this->RecordCount() > 0) {
            $content .= '<a class="category-links" href="' . zen_href_link(FILENAME_SPECIALS) . '">' . CATEGORIES_BOX_HEADING_SPECIALS . '</a>' . '<br />' . "\n";
          }
        }
        if (SHOW_CATEGORIES_BOX_PRODUCTS_NEW == 'true') {
          // display limits
    //      $display_limit = zen_get_products_new_timelimit();
          $display_limit = zen_get_new_date_range();
    
          $show_this = $db->Execute("select p.products_id
                                     from " . TABLE_PRODUCTS . " p
                                     where p.products_status = 1 " . $display_limit . " limit 1");
          if ($show_this->RecordCount() > 0) {
            $content .= '<a class="category-links" href="' . zen_href_link(FILENAME_PRODUCTS_NEW) . '">' . CATEGORIES_BOX_HEADING_WHATS_NEW . '</a>' . '<br />' . "\n";
          }
        }
        if (SHOW_CATEGORIES_BOX_FEATURED_PRODUCTS == 'true') {
          $show_this = $db->Execute("select products_id from " . TABLE_FEATURED . " where status= 1 limit 1");
          if ($show_this->RecordCount() > 0) {
            $content .= '<a class="category-links" href="' . zen_href_link(FILENAME_FEATURED_PRODUCTS) . '">' . CATEGORIES_BOX_HEADING_FEATURED_PRODUCTS . '</a>' . '<br />' . "\n";
          }
        }
        if (SHOW_CATEGORIES_BOX_PRODUCTS_ALL == 'true') {
          $content .= '<a class="category-links" href="' . zen_href_link(FILENAME_PRODUCTS_ALL) . '">' . CATEGORIES_BOX_HEADING_PRODUCTS_ALL . '</a>' . "\n";
        }
      }
      $content .= '</div>';
    ?>

    thanks so so much i appreciate your help so much

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

    Default Re: Parent Categories Separated In 3 sideboxes

    Try this and see if it works. It is the default file with the display test code added.
    You will need to edit cPaths to match your store's.

    PHP Code:
    <?php
    /**
     * Side Box Template
     *
     * @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_categories.php 4162 2006-08-17 03:55:02Z ajeh $
     */
      
    $content "";
      
      
    $content .= '<div id="' str_replace('_''-'$box_id 'Content') . '" class="sideBoxContent">' "\n";
      for (
    $i=0;$i<sizeof($box_categories_array);$i++) {
        
    /* test for cats to display */
        
    if ($box_categories_array[$i]['path'] == ('cPath=3' or 'cPath=7' or 'cPath=7_25' or 'cPath=7_26' or 'cPath=12')) {

        switch(
    true) {
    // to make a specific category stand out define a new class in the stylesheet example: A.category-holiday
    // uncomment the select below and set the cPath=3 to the cPath= your_categories_id
    // many variations of this can be done
    //      case ($box_categories_array[$i]['path'] == 'cPath=3'):
    //        $new_style = 'category-holiday';
    //        break;
          
    case ($box_categories_array[$i]['top'] == 'true'):
            
    $new_style 'category-top';
            break;
          case (
    $box_categories_array[$i]['has_sub_cat']):
            
    $new_style 'category-subs';
            break;
          default:
            
    $new_style 'category-products';
          }
         if (
    zen_get_product_types_to_category($box_categories_array[$i]['path']) == or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1)) {
            
    // skip if this is for the document box (==3)
          
    } else {
          
    $content .= '<a class="' $new_style '" href="' zen_href_link(FILENAME_DEFAULT$box_categories_array[$i]['path']) . '">';

          if (
    $box_categories_array[$i]['current']) {
            if (
    $box_categories_array[$i]['has_sub_cat']) {
              
    $content .= '<span class="category-subs-parent">' $box_categories_array[$i]['name'] . '</span>';
            } else {
              
    $content .= '<span class="category-subs-selected">' $box_categories_array[$i]['name'] . '</span>';
            }
          } else {
            
    $content .= $box_categories_array[$i]['name'];
          }

          if (
    $box_categories_array[$i]['has_sub_cat']) {
            
    $content .= CATEGORIES_SEPARATOR;
          }
          
    $content .= '</a>';

          if (
    SHOW_COUNTS == 'true') {
            if ((
    CATEGORIES_COUNT_ZERO == '1' and $box_categories_array[$i]['count'] == 0) or $box_categories_array[$i]['count'] >= 1) {
              
    $content .= CATEGORIES_COUNT_PREFIX $box_categories_array[$i]['count'] . CATEGORIES_COUNT_SUFFIX;
            }
          }

          
    $content .= '<br />' "\n";
        }
        } 
    /* end cat display test */
      
    }

      if (
    SHOW_CATEGORIES_BOX_SPECIALS == 'true' or SHOW_CATEGORIES_BOX_PRODUCTS_NEW == 'true' or SHOW_CATEGORIES_BOX_FEATURED_PRODUCTS == 'true' or SHOW_CATEGORIES_BOX_PRODUCTS_ALL == 'true') {
    // display a separator between categories and links
        
    if (SHOW_CATEGORIES_SEPARATOR_LINK == '1') {
          
    $content .= '<hr id="catBoxDivider" />' "\n";
        }
        if (
    SHOW_CATEGORIES_BOX_SPECIALS == 'true') {
          
    $show_this $db->Execute("select s.products_id from " TABLE_SPECIALS " s where s.status= 1 limit 1");
          if (
    $show_this->RecordCount() > 0) {
            
    $content .= '<a class="category-links" href="' zen_href_link(FILENAME_SPECIALS) . '">' CATEGORIES_BOX_HEADING_SPECIALS '</a>' '<br />' "\n";
          }
        }
        if (
    SHOW_CATEGORIES_BOX_PRODUCTS_NEW == 'true') {
          
    // display limits
    //      $display_limit = zen_get_products_new_timelimit();
          
    $display_limit zen_get_new_date_range();

          
    $show_this $db->Execute("select p.products_id
                                     from " 
    TABLE_PRODUCTS " p
                                     where p.products_status = 1 " 
    $display_limit " limit 1");
          if (
    $show_this->RecordCount() > 0) {
            
    $content .= '<a class="category-links" href="' zen_href_link(FILENAME_PRODUCTS_NEW) . '">' CATEGORIES_BOX_HEADING_WHATS_NEW '</a>' '<br />' "\n";
          }
        }
        if (
    SHOW_CATEGORIES_BOX_FEATURED_PRODUCTS == 'true') {
          
    $show_this $db->Execute("select products_id from " TABLE_FEATURED " where status= 1 limit 1");
          if (
    $show_this->RecordCount() > 0) {
            
    $content .= '<a class="category-links" href="' zen_href_link(FILENAME_FEATURED_PRODUCTS) . '">' CATEGORIES_BOX_HEADING_FEATURED_PRODUCTS '</a>' '<br />' "\n";
          }
        }
        if (
    SHOW_CATEGORIES_BOX_PRODUCTS_ALL == 'true') {
          
    $content .= '<a class="category-links" href="' zen_href_link(FILENAME_PRODUCTS_ALL) . '">' CATEGORIES_BOX_HEADING_PRODUCTS_ALL '</a>' "\n";
        }
      }
      
    $content .= '</div>';
    ?>

  3. #13
    Join Date
    Jan 2005
    Location
    Minneapolis MN, USA
    Posts
    136
    Plugin Contributions
    1

    Default Re: Parent Categories Separated In 3 sideboxes

    Hi,

    I'm coming late to this discussion, but there's a pretty simple way to my mind... something similar to what I've done with a site that had special needs re displaying the categories. Simply modify a function/query in the \includes\classes\category_tree.php to select based on the top level category.

    Here's an overview....

    1. Set up an Adult Category that contains all the categories of adult clothing; set up one for Teens and one for Children.

    2. Write down the Category ID # for each of them.

    3. In \includes\classes\category_tree.php you need to duplicate the entire "function zen_category_tree" section, renaming the function... for instance, "function zen_adult_tree".

    4. Find this section and add the text in red, replacing the # with your number from Step 2 above:
    Code:
        if ($product_type == 'all') { // added c.categories_id specific here bpeters
          $categories_query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image
                                 from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
                                 where c.parent_id = 0
                                 and c.categories_id = #
                                 and c.categories_id = cd.categories_id
                                 and cd.language_id='" . (int)$_SESSION['languages_id'] . "'
                                 and c.categories_status= 1
                                 order by sort_order, cd.categories_name";
        } else
    5. Duplicate the Categories Sidebox, title it Adult or whatever... change the function call to call the newly defined "tree" in \includes\modules\sideboxes\[your template]\categories.php as shown in red text:
    Code:
    // don't build a tree when no categories
        $check_categories = $db->Execute("select categories_id from " . TABLE_CATEGORIES . " where categories_status=1 limit 1");
        if ($check_categories->RecordCount() > 0) {
          $box_categories_array = $main_category_tree->zen_adult_tree();
        }
    Of course changing adult to whatever you need for each box.

    6. I don't know if you'll need to change anything if you're using the Site Map contrib or not, so you might want to check if that applies to your site.

    7. Be aware that the categories may not be expanded in the sidebox to display the subcategories all the time, and the boxes would have one link to "Adult Clothing" and not show anything else until you click on the category link itself. I can't remember what the upshot of this was, because I made additional changes beyond this for that site to meet their specific needs. But that sticks in my mind for some reason.

    ** Be advised that the mod to the class file will be overwritten during an upgrade, so be sure to save a copy of that file elsewhere -- there is no override in that section. And modifying core code is not always best, but this works and is easy. "-)

    I got this from digging around in the forum, found an old post by Ajeh I think that mentioned this method of doing something similar. Anyway, just an idea in case you don't get the other thing working.

    Just my two cents!

    Cheers,

    Becky

  4. #14
    Join Date
    Nov 2005
    Posts
    101
    Plugin Contributions
    0

    Default Re: Parent Categories Separated In 3 sideboxes

    ok so im playing with both of these to see which i can get working and which works best.

    Webomat thanks so much for the help, i have one question though. im not to experienced with php i have learned alot and learning more every day i assume i know when the function ends but i keep getting errors. so this leads me to think i have no clue*L*
    here is a small part of the code i just want to make sure im doing it right

    is the area in red the function i need to duplicate? or am i totally off.
    could you tell me exactly what starts and ends this function also where do i place it after copying it? right after the original function i assume.
    i understand the rest of how to do this im just confused about where the function starts and ends.

    Code:
    class category_tree extends base {
      function zen_category_tree($product_type = "all")   {
       global $db, $cPath, $cPath_array;
       if ($product_type != 'all') {   
          $sql = "select type_master_type from " . TABLE_PRODUCT_TYPES . "
                    where type_master_type = " . $product_type . "";
          $master_type_result = $db->Execute($sql);
          $master_type = $master_type_result->fields['type_master_type'];
     
        }    
     
        $this->tree = array();
        if ($product_type == 'all') {
          $categories_query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image
                                 from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
                                 where c.parent_id = 0  
                                 and c.categories_id = cd.categories_id
                                 and cd.language_id='" . (int)$_SESSION['languages_id'] . "'
                                 and c.categories_status= 1
                                 order by sort_order, cd.categories_name";
        } else {
          $categories_query = "select ptc.category_id as categories_id, cd.categories_name, c.parent_id, c.categories_image
                                 from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd, " . TABLE_PRODUCT_TYPES_TO_CATEGORY . " ptc
                                 where c.parent_id = 0  
                                 and ptc.category_id = cd.categories_id
                                 and ptc.product_type_id = " . $master_type . "
                                 and c.categories_id = ptc.category_id
                                 and cd.language_id=" . (int)$_SESSION['languages_id'] ."
                                 and c.categories_status= 1
                                 order by sort_order, cd.categories_name";
        }
    thanks so much for your help

  5. #15
    Join Date
    Nov 2005
    Posts
    101
    Plugin Contributions
    0

    Default Re: Parent Categories Separated In 3 sideboxes

    gjh42 ,

    i think your way is going to work best. but im still having problems. let me explain further maybe i left something out. i have cloned the categories sidebox three times i now have categories,categories2,categories3 and categories4 these are how i named the files. so i copied the code you gave me and put it in the tpl_categoreis2.php file as this is the sidebox im trying to change now in tpl_categories2.php there are a number of file names like this $box_categories_array should i add a 2 to the end of categories to match the file name or should i leave it as $box_categories_array
    when i change the $box_categories_array to $box_categories2_array it empties the categories out of the sidebox

    after copying what you gave me it did not do anything.
    when you say c-path you mean the categoryid right?


    i really appreciate your help, i hope i have explained myself OK.

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

    Default Re: Parent Categories Separated In 3 sideboxes

    I don't know about the $box_categories_array part of the code... but my inclination would be to leave that as is. If you change it, you may need to carry changes far & wide.

    The test code needs to say ('cPath=3' or 'cPath=7' or 'cPath=7_25' or ...) exactly, only replacing the numbers with yours. Of course you can add as many cPath items to the list as you want.
    You can get the correct cPaths by navigating to the cat or sub in your store and looking at the address bar.

    Note: You may want to try the modified code in the original tpl_categories.php first, to see how it works in something that you know is ok otherwise. One step at a time...
    Last edited by gjh42; 7 Apr 2007 at 10:05 PM.

  7. #17
    Join Date
    Nov 2005
    Posts
    101
    Plugin Contributions
    0

    Default Re: Parent Categories Separated In 3 sideboxes

    hmmm yeah that's exactly what i did but nothing is showing up.
    i though i did it right, you explained it well. i don't get why it wont work.

    i though this would be easier*L*, i should have know better

    i appreciate all your help

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

    Default Re: Parent Categories Separated In 3 sideboxes

    Something just occurred to me: the if test may not actually function properly as written. It is intuitively reasonable, but it might be that the comparison logic works differently. I haven't found a solid answer to this yet... will keep looking.

    Meanwhile, limiting the test to one 'cPath=3' will avoid this possible problem. If that works, we can reformulate the test statement.
    PHP Code:
      if (($box_categories_array[$i]['path'] == 'cPath=3') or ($box_categories_array[$i]['path'] == 'cPath=7') or ($box_categories_array[$i]['path'] == 'cPath=7_25')) { 
    will definitely work, but is unbelievably cumbersome for a long list. There will be a more elegant way of stating it.

    I suppose the first space-saver would be to substitute a simple variable for the $box expression.
    PHP Code:
        $cPTest $box_categories_array[$i]['path'];
        if ((
    $cPTest == 'cPath=3') or ($cPTest == 'cPath=7') or($cPTest == 'cPath=7_25')) } 
    is not so bad.

    Hope this will do it.

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

    Default Re: Parent Categories Separated In 3 sideboxes

    A little research gave me this (turn the cPath list into an array, then see if $box matches any array item):
    PHP Code:
     if(in_array($box_categories_array[$i]['path'], explode(",",'cPath=3','cPath=7','cPath=7_25'))) { 
    After I came up with this, I realized it is the same method used in tpl_main_page.php to turn off sideboxes on specified pages.

    If the cat list is long, a further condensation is possible:
    PHP Code:
    $cPTest str_replace("=","",strchr($box_categories_array[$i]['path'],"="));
    if(
    in_array($cPTestexplode(",",'3','7','7_25'))) { 
    Strchr will return the $box value from = to the end, and str_replace will strip the =, giving a smaller string to test for.

  10. #20
    Join Date
    Nov 2005
    Posts
    101
    Plugin Contributions
    0

    Default Re: Parent Categories Separated In 3 sideboxes

    ok i think we are getting close. i tried using the code from post 19 but i kept getting parse errors. i tired the codes from post 18 this one seemed to work

    Code:
    [FONT=Courier New]if (($box_categories_array[$i]['path'] == 'cPath=42') or ($box_categories_array[$i]['path'] == 'cPath=51') or ($box_categories_array[$i]['path'] == 'cPath=70'[/FONT][FONT=Courier New])) {  [/FONT]
    but it would only show two categories it would not show the third and if i added more to the array it would not show those either.

    i also tried this code

    Code:
    [FONT=Courier New]$cPTest = $box_categories_array[$i]['path'[/FONT][FONT=Courier New]];[/FONT]
    [FONT=Courier New]   if (($cPTest == 'cPath=3') or ($cPTest == 'cPath=7') or($cPTest == 'cPath=7_25'[/FONT][FONT=Courier New])) }  [/FONT]
    but it gave me this error


    Code:
    Parse error: syntax error, unexpected '}' in /home/cara1977/public_html/gothenaturalway/includes/templates/classic/sideboxes/tpl_categories.php on line 15
    i know i keep saying it but i appreciate your help so much, im going to keep playing with this a little bit code 1 above seem to work best so far i just need to get it to show more then two categories.

    thanks a ton
    Last edited by Kim; 29 Aug 2007 at 05:10 AM.

 

 
Page 2 of 7 FirstFirst 1234 ... LastLast

Similar Threads

  1. Category Filter - Display Parent categories
    By djdavedawson in forum General Questions
    Replies: 1
    Last Post: 5 Oct 2010, 10:08 PM
  2. Subcategories products in Parent Categories
    By fightthefourwalls in forum Setting Up Categories, Products, Attributes
    Replies: 21
    Last Post: 14 Jun 2010, 07:58 PM
  3. Enable Links for Parent Categories in Categories Sidebox
    By MrsQ in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 11 Sep 2009, 08:25 PM
  4. Parent... Child... Sub.... CATEGORIES
    By eliza-bee in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 12 May 2009, 03:03 PM
  5. Parent categories in dropdown filter
    By Ben in forum Customization from the Admin
    Replies: 3
    Last Post: 15 Aug 2006, 02:38 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR