Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2009
    Location
    Kilauea, Kauai - Hawaii
    Posts
    21
    Plugin Contributions
    0

    help question Categories with ezpages links & TOC Add On Question

    Aloha!

    Working on Newest Zen Cart.... First Timers etc...

    So far so good! I added the Add On:

    "Categories with ezpages links & TOC
    Author: Steve


    This mod will enable you to display links to your ezpages in the categories sidebox. This mod will replace your existing modules/sideboxes/categories.php, and templates/template_default/sideboxes/tpl_categories.php files. The original files will be renamed with .old

    All runs well, but since i am not a PHP crack... more a Pixelartist HTML/CSS all no big I am willing to learn... is fun so far...

    WHAT I LIKE TO DO:
    is to have the EZ Page Links before the Product Links...
    >>LINK>>here you can check out the shop I working on<<LINK<<


    So I looked in the two files but there is no easy "I copy this part above the other... " Maybe some very nice PHPer can help me to find this part that defines what comes first.....

    So here the code of
    A: Categories.php followed by B: tpl_categories.php
    A:
    PHP Code:
    <?php
    /**
     * categories sidebox - prepares content for the main categories sidebox
     *
     * @package templateSystem
     * @copyright Copyright 2003-2005 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: categories.php 2718 2005-12-28 06:42:39Z drbyte $
     * @Modded by Steve(strelitzia) to allow ezpages links to be displayed in categories sidebox
     */

        
    $main_category_tree = new category_tree;
        
    $row 0;
        
    $box_categories_array = array();

    // 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_category_tree();
        }
        
    $title BOX_HEADING_CATEGORIES;
        
    $title_link false;
        
        
    // test if sidebox should display
      
    if (EZPAGES_STATUS_SIDEBOX == '1' or (EZPAGES_STATUS_SIDEBOX== '2' and (strstr(EXCLUDE_ADMIN_IP_FOR_MAINTENANCE$_SERVER['REMOTE_ADDR'])))) {
        if (isset(
    $var_linksList)) {
          unset(
    $var_linksList);
        }
        
    $page_query $db->Execute("select * from " TABLE_EZPAGES " where status_sidebox = 1 and sidebox_sort_order > 0 order by sidebox_sort_order, pages_title");
        if (
    $page_query->RecordCount()>0) {
          
    $rows 0;
          while (!
    $page_query->EOF) {
            
    $rows++;
            
    $page_query_list_sidebox[$rows]['id'] = $page_query->fields['pages_id'];
            
    $page_query_list_sidebox[$rows]['name'] = $page_query->fields['pages_title'];
            
    $page_query_list_sidebox[$rows]['altURL']  = "";
            switch (
    true) {
              
    // external link new window or same window
              
    case ($page_query->fields['alt_url_external'] != ''):
              
    $page_query_list_sidebox[$rows]['altURL']  = $page_query->fields['alt_url_external'];
              break;
              
    // internal link new window
              
    case ($page_query->fields['alt_url'] != '' and $page_query->fields['page_open_new_window'] == '1'):
              
    $page_query_list_sidebox[$rows]['altURL']  = (substr($page_query->fields['alt_url'],0,4) == 'http') ?
              
    $page_query->fields['alt_url'] :
              (
    $page_query->fields['alt_url']=='' '' zen_href_link($page_query->fields['alt_url'], '', ($page_query->fields['page_is_ssl']=='0' 'NONSSL' 'SSL'), truetruetrue));
              break;
              
    // internal link same window
              
    case ($page_query->fields['alt_url'] != '' and $page_query->fields['page_open_new_window'] == '0'):
              
    $page_query_list_sidebox[$rows]['altURL']  = (substr($page_query->fields['alt_url'],0,4) == 'http') ?
              
    $page_query->fields['alt_url'] :
              (
    $page_query->fields['alt_url']=='' '' zen_href_link($page_query->fields['alt_url'], '', ($page_query->fields['page_is_ssl']=='0' 'NONSSL' 'SSL'), truetruetrue));
              break;
            }

            
    // if altURL is specified, use it; otherwise, use EZPage ID to create link
            
    $page_query_list_sidebox[$rows]['link'] = ($page_query_list_sidebox[$rows]['altURL'] =='') ?
            
    zen_href_link(FILENAME_EZPAGES'id=' $page_query->fields['pages_id'] . ($page_query->fields['toc_chapter'] > '&chapter=' $page_query->fields['toc_chapter'] : ''), ($page_query->fields['page_is_ssl']=='0' 'NONSSL' 'SSL')) :
            
    $page_query_list_sidebox[$rows]['altURL'];
            
    $page_query_list_sidebox[$rows]['link'] .= ($page_query->fields['page_open_new_window'] == '1' '" target="_blank' '');
            
    $page_query->MoveNext();
          }

          
    $var_linksList $page_query_list_sidebox;
     }
      } 
    // test for display
       
    unset($ez_pages_toc);

    $pages_order_toc_query "SELECT *
                          FROM " 
    TABLE_EZPAGES "
                          WHERE ((status_toc = 1 and toc_sort_order <> 0) and toc_chapter= :chapterID )
                          AND alt_url_external = '' and alt_url = ''
                          ORDER BY toc_sort_order, pages_title"
    ;

    $pages_order_toc_query $db->bindVars($pages_order_toc_query':chapterID'$chapter_id'integer');
    $pages_listing_toc $db->execute($pages_order_toc_query);

    // test if links should display
        
    while (!$pages_listing_toc->EOF) {
    // could be used to change classes on current link and toc (table of contents) links
          
    if ($pages_listing_toc->fields['pages_id'] == $_GET['id']) {
            
    $ez_pages_toc[] = '<div>' CURRENT_PAGE_INDICATOR '<a href="' zen_ez_pages_link($pages_listing_toc->fields['pages_id']) . '">' $pages_listing_toc->fields['pages_title'] . '</a>' '</div>';
          } else {
            
    $ez_pages_toc[] = '<div>' NOT_CURRENT_PAGE_INDICATOR '<a href="' zen_ez_pages_link($pages_listing_toc->fields['pages_id']) . '">' $pages_listing_toc->fields['pages_title'] . '</a>' '</div>';
          }
          
    $pages_listing_toc->MoveNext();
        }

    // only show if there is an EZ-PAGES TOC
      
    if (sizeof($ez_pages_toc) > 0) {
        
      }
          require(
    $template->get_template_dir('tpl_categories.php',DIR_WS_TEMPLATE$current_page_base,'sideboxes'). '/tpl_categories.php');
          require(
    $template->get_template_dir($column_box_defaultDIR_WS_TEMPLATE$current_page_base,'common') . '/' $column_box_default);
        
        
    ?>
    -----------------------------------
    B: tpl_categories.php

    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++) {
        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";
        }
      }

    // integrate ezpages

      
    $content  .= "\n" '<ul style="margin: 0; padding: 0; list-style-type: none;">' "\n";
      for (
    $i=1$n=sizeof($var_linksList); $i<=$n$i++) { 
        
    $content .= '<li><a href="' $var_linksList[$i]['link'] . '">' $var_linksList[$i]['name'] . '</a></li>' "\n" ;
      } 
    // end FOR loop
      
    $content  .= '</ul>' "\n";
     
    //end integrate ezpages
    // integrate ezpges TOC
     
    $content .=  "\n" '<ul style="margin: 0; padding: 0; list-style-type: none;">' "\n" ;
      for (
    $i=0$i<sizeof($ez_pages_toc); $i++) {
        
    $content .= '<li>' $ez_pages_toc[$i] . '</li>' "\n" ;
      }

      
    $content .= '</ul>' "\n" ;


    // end integrate ezpages TOC

      
    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>';
    ?>
    Mahalo from Kauai - Leialoha

  2. #2
    Join Date
    Feb 2009
    Location
    Kilauea, Kauai - Hawaii
    Posts
    21
    Plugin Contributions
    0

    Default Re: Categories with ezpages links & TOC Add On Question

    Bought myself now a PHP book...

  3. #3
    Join Date
    Jan 2007
    Posts
    169
    Plugin Contributions
    0

    Default Re: Categories with ezpages links & TOC Add On Question

    To switch the order change your tpl_categories.php to look like this ...

    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";
      
      // code is now here
      // integrate ezpages
      $content  .= "\n" . '<ul style="margin: 0; padding: 0; list-style-type: none;">' . "\n";
      for ($i=1, $n=sizeof($var_linksList); $i<=$n; $i++) { 
        $content .= '<li><a href="' . $var_linksList[$i]['link'] . '">' . $var_linksList[$i]['name'] . '</a></li>' . "\n" ;
      } // end FOR loop
      $content  .= '</ul>' . "\n";
     
        //end integrate ezpages
        // integrate ezpges TOC
         $content .=  "\n" . '<ul style="margin: 0; padding: 0; list-style-type: none;">' . "\n" ;
          for ($i=0; $i<sizeof($ez_pages_toc); $i++) {
            $content .= '<li>' . $ez_pages_toc[$i] . '</li>' . "\n" ;
          }
        
          $content .= '</ul>' . "\n" ;
        
        
        // end integrate ezpages TOC
    
      
      
      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";
        }
      }
    
    // code used to be here
    
      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>';
    ?>
    I just move the location of a section of code. Look for the comments "// code used to be here". And look for the comment "// code is now here".

  4. #4
    Join Date
    Feb 2009
    Location
    Kilauea, Kauai - Hawaii
    Posts
    21
    Plugin Contributions
    0

    Default Re: Categories with ezpages links & TOC Add On Question

    Mahalo !!!! (thanks in hawaiian)!!!

    Much for your effort.... I will look into it, has been a while ... still love zen cart...

 

 

Similar Threads

  1. v151 EZPages TOC
    By rush_woman in forum General Questions
    Replies: 2
    Last Post: 8 Oct 2013, 04:12 AM
  2. v150 Moving Home & Login to ezpages links navbar
    By ckelley in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 30 Jul 2012, 09:02 PM
  3. EZPages TOC Sidebox
    By Ajeh in forum Addon Sideboxes
    Replies: 18
    Last Post: 7 Dec 2008, 05:55 PM
  4. Categories sidebox with EZpages links
    By strelitzia in forum Addon Sideboxes
    Replies: 3
    Last Post: 26 Sep 2008, 10:20 AM
  5. EZ-Pages TOC & Internal Links
    By MattC in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 16 Nov 2006, 07:21 AM

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