Zen Cart Logo
Forums / Addon Sideboxes / Expanded Category List - make it a page and not a sidebox

Expanded Category List - make it a page and not a sidebox

Locked

Views: 2,811

Results 1 to 12 of 12
This thread is locked. New replies are disabled.
15 Feb 2008, 4:48 PM
#1
bradymc avatar

bradymc

New Zenner

Join Date:
Feb 2007
Location:
Dallas area
Posts:
75
Plugin Contributions:
0

Expanded Category List - make it a page and not a sidebox

Is it possible to modify this sidebox so that the same results would display in the content area of a page instead of in a sidebox?

15 Feb 2008, 6:41 PM
#2
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Expanded Category List - make it a page and not a sidebox

You can always study its template file and use that code anywhere you want.

15 Feb 2008, 6:55 PM
#3
bradymc avatar

bradymc

New Zenner

Join Date:
Feb 2007
Location:
Dallas area
Posts:
75
Plugin Contributions:
0

Re: Expanded Category List - make it a page and not a sidebox

I've been working on that and I'm not having much luck on my own. Switching it from a sidebox to a template page is probably easy for someone who knows how... however I don't fall into that category.

I thought I could just do some things like move the file from the sidebox directory to the templates directory and change some require functions, etc., etc.... nope!

15 Feb 2008, 6:56 PM
#4
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Expanded Category List - make it a page and not a sidebox

You will actually need to copy most of the content of the sidebox template file, not the file itself.

15 Feb 2008, 7:03 PM
#5
bradymc avatar

bradymc

New Zenner

Join Date:
Feb 2007
Location:
Dallas area
Posts:
75
Plugin Contributions:
0

Re: Expanded Category List - make it a page and not a sidebox

Are you saying to copy the content of the sidebox template file and use that information to create a new page template file?

15 Feb 2008, 7:13 PM
#6
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Expanded Category List - make it a page and not a sidebox

Yup, exactly.

15 Feb 2008, 7:32 PM
#7
bradymc avatar

bradymc

New Zenner

Join Date:
Feb 2007
Location:
Dallas area
Posts:
75
Plugin Contributions:
0

Re: Expanded Category List - make it a page and not a sidebox

I guess what seems to be getting me is what should go in the header file...
/includes/modules/pages/MY_PAGE_NAME/header_php.php.

Again, I tried copying the information from \includes\modules\sideboxes\YOUR_TEMPLATE\category_list_box.php and change a few settings, but it keeps kicking out warnings and fatal errors.

15 Feb 2008, 7:37 PM
#8
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Expanded Category List - make it a page and not a sidebox

Send me the link to that exact page.

15 Feb 2008, 8:17 PM
#9
bradymc avatar

bradymc

New Zenner

Join Date:
Feb 2007
Location:
Dallas area
Posts:
75
Plugin Contributions:
0

Re: Expanded Category List - make it a page and not a sidebox

So now I sit on a blank page.

Here's my header file minus the comments and php tags:

require DIR_WS_CLASSES . 'category_list.php'; 
    $main_category_list = new category_list;
    $main_category_list->category_list();
    $row = 0;
    $box_categories_array = array();    
    $box_categories_array = $main_category_list->build_list();
    
    require($template->get_template_dir('tpl_category_listing.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_category_listing.php');    
        
    $title = BOX_HEADING_CATEGORY_LIST;
    $left_corner = false;
    $right_corner = false;
    $right_arrow = false;
    $title_link = false;
```And here's what's in my template file:
```php
$content = "";
    $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">' . "\n";

  for ($i=0;$i<sizeof($box_categories_array);$i++) {
     
     //set selected style ($box_categories_array[$i]['current'] does not work)    
     $div_class='';
     if ($products_id){
         if (($products_id)&&($box_categories_array[$i]['products_id']==$products_id)){
             $div_class='category-subs-selected';
         }
     }else{
         if(($current_category_id!=0)&&($box_categories_array[$i]['category_id']==$current_category_id)){
             $div_class='category-subs-selected';
         }
     }              
    
    // set top style
    if ($box_categories_array[$i]['top'] == 'true'){    
        $a_class = 'category-top';
    }elseif($box_categories_array[$i]['has_sub_cat']){
        $a_class = 'category-subs';
    }else{
        $a_class='category-products';
    }
     // link to cat or prod
    if ($box_categories_array[$i]['is_product'] == true){
        $link = zen_href_link(FILENAME_PRODUCT_INFO, $box_categories_array[$i]['path']);
    }else{
        $link = zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']);
    }    
    //indent
    if($box_categories_array[$i]['is_product'] == true){
        $indent = str_repeat(CATEGORIES_SUBCATEGORIES_INDENT,  $box_categories_array[$i]['level']+1); 
    }else{
        $indent = str_repeat(CATEGORIES_SUBCATEGORIES_INDENT,  $box_categories_array[$i]['level']); 
    }
    //cat sub seperator
    if (($box_categories_array[$i]['level'] == 0)&&($box_categories_array[$i]['is_product'] == false)){
        $separator = '';
    }else{
        $separator = CATEGORIES_SEPARATOR_SUBS;
    }
    // count
    $count='';
    if (SHOW_COUNTS == 'true') {
        if($box_categories_array[$i]['is_product'] != true){
            $count = CATEGORIES_SEPARATOR.CATEGORIES_COUNT_PREFIX . $box_categories_array[$i]['count'] . CATEGORIES_COUNT_SUFFIX ;
        }
    }
    //add content
    $content .= '<span class="'. $div_class .'">'. 
        $indent.$separator.'<a class="'. $a_class .'" href="'. $link .'">'. $box_categories_array[$i]['name'] .'</a>'. $count .
    '</span><br />';
    
  }


  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 />';
      }
    }
    if (SHOW_CATEGORIES_BOX_PRODUCTS_NEW == 'true') {
      switch (true) {
        case (SHOW_NEW_PRODUCTS_LIMIT == '0'):
          $display_limit = '';
          break;
        case (SHOW_NEW_PRODUCTS_LIMIT == '1'):
          $display_limit = " and date_format(p.products_date_added, '%Y%m') >= date_format(now(), '%Y%m')";
          break;
        case (SHOW_NEW_PRODUCTS_LIMIT == '30'):
          $display_limit = ' and TO_DAYS(NOW()) - TO_DAYS(p.products_date_added) <= 30';
          break;
        case (SHOW_NEW_PRODUCTS_LIMIT == '60'):
          $display_limit = ' and TO_DAYS(NOW()) - TO_DAYS(p.products_date_added) <= 60';
          break;
        case (SHOW_NEW_PRODUCTS_LIMIT == '90'):
          $display_limit = ' and TO_DAYS(NOW()) - TO_DAYS(p.products_date_added) <= 90';
          break;
        case (SHOW_NEW_PRODUCTS_LIMIT == '120'):
          $display_limit = ' and TO_DAYS(NOW()) - TO_DAYS(p.products_date_added) <= 120';
          break;
      }

      $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 />';
      }
    }
    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 />';
      }
    }
    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>';
    }
  }
    $content .= '</div>';
```Should I have this template code in includes/languages/english/html_includes/MY_TEMPLATE/define_my_page.php?
16 Feb 2008, 12:05 AM
#10
bradymc avatar

bradymc

New Zenner

Join Date:
Feb 2007
Location:
Dallas area
Posts:
75
Plugin Contributions:
0

Re: Expanded Category List - make it a page and not a sidebox

Ok, I'm slowly making progress. I finally got things situated so that the page is just waiting for me to display content. I assume that the code shown above is what should be in the html_includes file, but that isn't displaying anything on the page. I can replace it all with "abcdefg" and those letters will show on the page so I know I'm on the right track. Is the code above what should be in the html_includes file?

16 Feb 2008, 3:22 AM
#11
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Expanded Category List - make it a page and not a sidebox

You do realize that, you have to print out the $content variable, do you?

echo $content;

16 Feb 2008, 4:23 AM
#12
bradymc avatar

bradymc

New Zenner

Join Date:
Feb 2007
Location:
Dallas area
Posts:
75
Plugin Contributions:
0

Re: Expanded Category List - make it a page and not a sidebox

:frusty:

Not only am I the president of the PHP-Newby club, I'm also a client. Thanks for all the pointers. I've managed to get everything working and formatted to my liking.