Zen Cart Logo
Forums / Addon Sideboxes / Categories with ezpages links & TOC Add On Question

Categories with ezpages links & TOC Add On Question

Locked

Views: 1,999

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
11 Feb 2009, 8:43 AM
#1
leialoha avatar

leialoha

New Zenner

Join Date:
Feb 2009
Location:
Kilauea, Kauai - Hawaii
Posts:
21
Plugin Contributions:
0

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...:laugh:

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

So I looked in the two files but there is:no: 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

<?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'), true, true, true)); 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'), true, true, true)); 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'] > 0 ? '&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_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default); ?>

----------------------------------- 
B:  tpl_categories.php

```php
<?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";
    }
  }

// 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 :sleepy:

23 Feb 2009, 8:24 AM
#2
leialoha avatar

leialoha

New Zenner

Join Date:
Feb 2009
Location:
Kilauea, Kauai - Hawaii
Posts:
21
Plugin Contributions:
0

Re: Categories with ezpages links & TOC Add On Question

Bought myself now a PHP book... :smartalec:

18 Aug 2009, 4:16 AM
#3
artcoder avatar

artcoder

Zen Follower

Join Date:
Jan 2007
Posts:
166
Plugin Contributions:
0

Re: Categories with ezpages links & TOC Add On Question

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

<?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".

18 Aug 2009, 4:48 AM
#4
leialoha avatar

leialoha

New Zenner

Join Date:
Feb 2009
Location:
Kilauea, Kauai - Hawaii
Posts:
21
Plugin Contributions:
0

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...