Zen Cart Logo
Forums / Addon Sideboxes / Categories Dressing

Categories Dressing

Views: 531,465

Results 241 to 260 of 2,268
01 May 2008, 07:59
#241
antheia avatar

antheia

New Zenner

Join Date:
Apr 2008
Posts:
30
Plugin Contributions:
0

Categories Dressing

i have downloaded this program but not sure how to put it into my server?

01 May 2008, 12:04
#242
antheia avatar

antheia

New Zenner

Join Date:
Apr 2008
Posts:
30
Plugin Contributions:
0

Re: Categories Dressing

ok i figured it out but have more questions.

How do i get rid of the 'link heading' with the bright pink backing that has put itself under new products? here... https://www.enchantedaura.com.au/products

06 May 2008, 03:48
#243
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Categories Dressing

See post #237 above.

11 May 2008, 20:53
#244
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Categories Dressing

Categories Dressing v2.2 is now available in Downloads.

The main feature is that the readme file has been changed to HTML for easier comprehension.
Notes in the readme about removing examples have been given emphasis.

I have also added title tags to foreground & background image links for better accessibility.

13 May 2008, 19:44
#245
baller_23 avatar

baller_23

New Zenner

Join Date:
May 2008
Posts:
15
Plugin Contributions:
0

Re: Categories Dressing

hi

i installed it on my site and it works just fine, Thanks!

but it shows a divider between digital consumables and batteries chargers.

why is that? Digital Consumables is currently the only cat with sub cat.

i added some sub cat to some other cats but there is no line...
the divider should only be between other and specials....

thanks in advance

Baller#23

14 May 2008, 04:51
#246
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Categories Dressing

The readme describes how to disable example features where you don't want to use them.

Change this php // categories dressing - add divider above specified cats if(in_array($current_path, explode(",",'3,22,21_56'))) { //replace numbers with your cat ids separated by commas to this```php
// categories dressing - add divider above specified cats
if(in_array($current_path, explode(",",''))) { //replace numbers with your cat ids separated by commas

20 May 2008, 00:09
#247
gsdcypher avatar

gsdcypher

Totally Zenned

Join Date:
Feb 2007
Posts:
816
Plugin Contributions:
0

Re: Categories Dressing

Hi,

So instead of commenting everything out, if I only want a a non-linked heading with a divider below the text, can I delete everything from the tpl_categories.php except this code??? *And just repeat from case to break; } for each heading?

      $disp_block_head = '';
      //$disp_block_head = '<br />';  // for heading not block uncomment this line
  ...
      // categories dressing - add (divider and) heading above a cat
      switch (str_replace("cPath=","",$box_categories_array[$i]['path'])) {
      case '10': //replace number with your desired cPath
        //$content .= '<hr class="catBoxDivider" />' . "\n";  // to add divider uncomment this line
        $content .= '<span class="catBoxHeading1">' . (file_exists(DIR_WS_TEMPLATE_IMAGES . 'cathead' . $current_path . '.gif') ? zen_image(DIR_WS_TEMPLATE_IMAGES . 'cathead' . $current_path . '.gif') . '</span>':'Heading 1</span>' . $disp_block_head) . "\n"; 
      break;
      } 
 
      case '20': //replace number with your desired cPath
        //$content .= '<hr class="catBoxDivider" />' . "\n";  // to add divider uncomment this line
        $content .= '<span class="catBoxHeading1">' . (file_exists(DIR_WS_TEMPLATE_IMAGES . 'cathead' . $current_path . '.gif') ? zen_image(DIR_WS_TEMPLATE_IMAGES . 'cathead' . $current_path . '.gif') . '</span>':'Heading 2</span>' . $disp_block_head) . "\n"; 
      break;
      }  
 
      case '30': //replace number with your desired cPath
        //$content .= '<hr class="catBoxDivider" />' . "\n";  // to add divider uncomment this line
        $content .= '<span class="catBoxHeading1">' . (file_exists(DIR_WS_TEMPLATE_IMAGES . 'cathead' . $current_path . '.gif') ? zen_image(DIR_WS_TEMPLATE_IMAGES . 'cathead' . $current_path . '.gif') . '</span>':'Heading 2</span>' . $disp_block_head) . "\n"; 
      break;
      } 

And delete everything from stylesheet_categories_dressing.css except this code???

.catBoxHeading1 { 
    font-family: 'times new roman', serif;
    font-weight: bold;
    font-size: 1.4em;
    color: #335511; 
    background-color: #ff66ff;
    /*background-image: url(../images/catheadbg1.gif); */ /*uncomment to use background image with or without coded text*/
    /*height: 23px; */ /*uncomment to use background image without coded text*/
    display: block;
    padding: 0.3em 0.4em;
    margin-top: 2px;
    margin-bottom: 2px;
    }  
20 May 2008, 07:47
#248
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Categories Dressing

There are a number of interdependent snippets of code throughout the file in recent versions of Cat Dressing, so I wouldn't advise deleting code without a full understanding of what you are doing. The readme tells how to disable examples you don't want to use.

You can definitely delete most of the stylesheet declarations that you are not using. The divider will occur above the heading text; if you want it below for all headings, you can simply add to your stylesheet's .catBoxHeading1 { declaration```
border-bottom: 1px solid #112233;

22 May 2008, 05:28
#249
gsdcypher avatar

gsdcypher

Totally Zenned

Join Date:
Feb 2007
Posts:
816
Plugin Contributions:
0

Re: Categories Dressing

Hi gjh42,

Still working with the two files... and I have two questions.

Right now the categories links are lined up under each other (standard zen cart):
HEADING
link
link
link

HEADING
link
link
link
etc.

But when I upload the categories.php the links follow each other:
HEADING
link link link link

HEADING
link link link etc.

  1. How do I make it so they line up under each other like the standard zen cart?
  2. The line break above each heading is not showing up... how do I get it to show?

This is my tpl_categories code:

 
 * Modified for Categories Dressing v2.2  by Glenn Herbert (gjh42)  2008-02-25
 */
  $disp_block = '';
  //$disp_block = '<br />'; //if not using display: block; in stylesheet, uncomment  this line
  $disp_block_head = '';
  //$disp_block_head = '<br />';  // for headings not block uncomment this line
  $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';
    }
 $current_path = str_replace("cPath=","",$box_categories_array[$i]['path']);
    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 {
      // categories dressing - add divider above specified cats
      if(in_array($current_path, explode(",",''))) { //replace numbers with your cat ids separated by commas
        $content .= '<hr class="catBoxDivider" />' . "\n";
      }
      // categories dressing - add (divider and) heading above a cat
   switch ($current_path) {
       case '62': //replace number with your desired cPath
        //$content .= '<hr class="catBoxDivider" />' . "\n";  // to add divider uncomment this line
        $content .= '<span class="catBoxHeading1">' . (file_exists(DIR_WS_TEMPLATE_IMAGES . 'cathead' . $current_path . '.gif') ? zen_image(DIR_WS_TEMPLATE_IMAGES . 'cathead' . $current_path . '.gif') . '</span>':'Dog Equipment</span>' . $disp_block_head) . "\n"; 
   break;
   
      case '121': //replace number with your desired cPath
        //$content .= '<hr class="catBoxDivider" />' . "\n";  // to add divider uncomment this line
        $content .= '<span class="catBoxHeading1">' . (file_exists(DIR_WS_TEMPLATE_IMAGES . 'cathead' . $current_path . '.gif') ? zen_image(DIR_WS_TEMPLATE_IMAGES . 'cathead' . $current_path . '.gif') . '</span>':'Dog Supplies</span>' . $disp_block_head) . "\n"; 
   break;
   
      case '52': //replace number with your desired cPath
        //$content .= '<hr class="catBoxDivider" />' . "\n";  // to add divider uncomment this line
        $content .= '<span class="catBoxHeading1">' . (file_exists(DIR_WS_TEMPLATE_IMAGES . 'cathead' . $current_path . '.gif') ? zen_image(DIR_WS_TEMPLATE_IMAGES . 'cathead' . $current_path . '.gif') . '</span>':'Clothing</span>' . $disp_block_head) . "\n"; 
   break;
   
      case '3': //replace number with your desired cPath
        //$content .= '<hr class="catBoxDivider" />' . "\n";  // to add divider uncomment this line
        $content .= '<span class="catBoxHeading1">' . (file_exists(DIR_WS_TEMPLATE_IMAGES . 'cathead' . $current_path . '.gif') ? zen_image(DIR_WS_TEMPLATE_IMAGES . 'cathead' . $current_path . '.gif') . '</span>':'Decoy & Helper</span>' . $disp_block_head) . "\n"; 
   break;
   
      case '133': //replace number with your desired cPath
        //$content .= '<hr class="catBoxDivider" />' . "\n";  // to add divider uncomment this line
        $content .= '<span class="catBoxHeading1">' . (file_exists(DIR_WS_TEMPLATE_IMAGES . 'cathead' . $current_path . '.gif') ? zen_image(DIR_WS_TEMPLATE_IMAGES . 'cathead' . $current_path . '.gif') . '</span>':'Tugs & Toys</span>' . $disp_block_head) . "\n"; 
   break;
   
      case '32': //replace number with your desired cPath
        //$content .= '<hr class="catBoxDivider" />' . "\n";  // to add divider uncomment this line
        $content .= '<span class="catBoxHeading1">' . (file_exists(DIR_WS_TEMPLATE_IMAGES . 'cathead' . $current_path . '.gif') ? zen_image(DIR_WS_TEMPLATE_IMAGES . 'cathead' . $current_path . '.gif') . '</span>':'Electric Collars</span>' . $disp_block_head) . "\n"; 
   break;
   
      case '48': //replace number with your desired cPath
        //$content .= '<hr class="catBoxDivider" />' . "\n";  // to add divider uncomment this line
        $content .= '<span class="catBoxHeading1">' . (file_exists(DIR_WS_TEMPLATE_IMAGES . 'cathead' . $current_path . '.gif') ? zen_image(DIR_WS_TEMPLATE_IMAGES . 'cathead' . $current_path . '.gif') . '</span>':'Training Aids</span>' . $disp_block_head) . "\n"; 
   break;   
      }  
   // categories dressing - category name mods
      $cat_name_display = $box_categories_array[$i]['name'];
//      $subcat_level = (substr_count($current_path, '_'); //strip out subcat indent 
//      $cat_name_display = substr_replace($cat_name_display,'',0,($subcat_level*strlen(CATEGORIES_SUBCATEGORIES_INDENT)));
   $cat_img_bg = '';
   // categories dressing - display image if exists for category name - with title tag
      if (file_exists(DIR_WS_TEMPLATE_IMAGES . 'catimg' . $current_path . '.gif')) {
        $cat_name_display = zen_image(DIR_WS_TEMPLATE_IMAGES . 'catimg' . $current_path . '.gif', '', '', '', 'title="' . $box_categories_array[$i]['name'] . '"'); 
   // categories dressing - display background image if exists for category name - with title tag
   } elseif (file_exists(DIR_WS_TEMPLATE_IMAGES . 'catbg' . $current_path . '.gif')) {
        $cat_name_display = zen_image(DIR_WS_TEMPLATE_IMAGES . 'pixel_trans.gif', '', '100%', '100%', 'title="' . $box_categories_array[$i]['name'] . '"');
        $cat_img_bg = ' catBg' . $current_path;
      } else {
     $cat_img_bg = '-text';//append to main classname
   }
      $content .= '<a class="' . $new_style . $cat_img_bg . '" 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">' . $cat_name_display . ($disp_block == '<br />'?'</span>':'');
        } else {
          $content .= '<span class="category-subs-selected">' . $cat_name_display . ($disp_block == '<br />'?'</span>':'');
        }
      } else {
        $content .= '<span class="category-not-selected">' . $cat_name_display . ($disp_block == '<br />'?'</span>':'');
      } // category name mods
      if ($box_categories_array[$i]['has_sub_cat']) {
        $content .= CATEGORIES_SEPARATOR;
      }
      $content .= ($disp_block == '<br />'?'</a>':''); // categories dressing - adjust link end 
      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 .= ($disp_block == ''?'</span></a>':'') . $disp_block . "\n"; // categories dressing - adjust link end 
      // categories dressing - add subtext below a cat
   switch ($current_path) {
   case '': //replace number with your desired cPath
        $content .= '<span class="catBoxSubtext">Subtext for cat 23 escape apostrophe\'s</span>' . $disp_block . "\n"; 
   break;
   } // subtext
    }
  }
  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') {
      //$content .= '<span class="catBoxHeading1">' . (file_exists(DIR_WS_TEMPLATE_IMAGES . 'cathead-specials.gif') ? zen_image(DIR_WS_TEMPLATE_IMAGES . 'cathead-specials.gif') . '</span>':'Link Heading</span>' . $disp_block_head) . "\n";// categories dressing - uncomment this line for heading above link 
      $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>' . $disp_block . "\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 .= '<span class="catBoxHeading1">' . (file_exists(DIR_WS_TEMPLATE_IMAGES . 'cathead-new.gif') ? zen_image(DIR_WS_TEMPLATE_IMAGES . 'cathead-new.gif') . '</span>':'Link Heading</span>' . $disp_block_head) . "\n";// categories dressing - uncomment this line for heading above link 
        $content .= '<a class="category-links" href="' . zen_href_link(FILENAME_PRODUCTS_NEW) . '">' . CATEGORIES_BOX_HEADING_WHATS_NEW . '</a>' . $disp_block . "\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 .= '<span class="catBoxHeading1">' . (file_exists(DIR_WS_TEMPLATE_IMAGES . 'cathead-featured.gif') ? zen_image(DIR_WS_TEMPLATE_IMAGES . 'cathead-featured.gif') . '</span>':'Link Heading</span>' . $disp_block_head) . "\n";// categories dressing - uncomment this line for heading above link 
        $content .= '<a class="category-links" href="' . zen_href_link(FILENAME_FEATURED_PRODUCTS) . '">' . CATEGORIES_BOX_HEADING_FEATURED_PRODUCTS . '</a>' . $disp_block . "\n";
      }
    }
    if (SHOW_CATEGORIES_BOX_PRODUCTS_ALL == 'true') {
      //$content .= '<span class="catBoxHeading1">' . (file_exists(DIR_WS_TEMPLATE_IMAGES . 'cathead-all.gif') ? zen_image(DIR_WS_TEMPLATE_IMAGES . 'cathead-all.gif') . '</span>':'Link Heading</span>' . $disp_block_head) . "\n";// categories dressing - uncomment this line for heading above link 
      $content .= '<a class="category-links" href="' . zen_href_link(FILENAME_PRODUCTS_ALL) . '">' . CATEGORIES_BOX_HEADING_PRODUCTS_ALL . '</a>' . "\n";
    }
  }
  $content .= '</div>';
?>

This is my style sheet code:

 
hr.catBoxDivider { 
    color: #aabbcc;
    }
.catBoxHeading1 { 
    font-family: "Lucida Grande", tahoma, verdana, arial, helvetica, sans-serif;
    font-weight: bold;
    font-size: 1.0em;
    color: #405489; 
    background-color: #FFFFFF;
    /*background-image: url(../images/catheadbg1.gif); */ /*uncomment to use background image with or without coded text*/
    /*height: 23px; */ /*uncomment to use background image without coded text*/
    display: block;
    padding: 0.3em 0.4em;
    margin-top: 2px;
    margin-bottom: 2px;
    }  

Thanks.

24 May 2008, 06:05
#250
gsdcypher avatar

gsdcypher

Totally Zenned

Join Date:
Feb 2007
Posts:
816
Plugin Contributions:
0

Re: Categories Dressing

Is it not possible to have the links displayed like this

HEADING
link
link
link
etc.

rather than this:

HEADING
link link link link

using the tpl_categories?

27 May 2008, 03:00
#251
gsdcypher avatar

gsdcypher

Totally Zenned

Join Date:
Feb 2007
Posts:
816
Plugin Contributions:
0

Re: Categories Dressing

Anyone know which piece of code controls how the links are listed? I want to change it from this:
HEADING
link link link etc.

To this:
HEADING
link
link
link

Thanks.

27 May 2008, 06:52
#252
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Categories Dressing

This is controlled by the display: block; or display: list-item; properties in your stylesheet. Cat Dressing by default does this, so you must have deleted some code lines or otherwise are not applying Cat Dressing as designed.

28 May 2008, 20:03
#253
busymom avatar

busymom

New Zenner

Join Date:
Jul 2007
Posts:
61
Plugin Contributions:
0

Re: Categories Dressing

Glenn, I adapted your Categories Dressing code for using an image for each of my EZPages link if one is available. I didn't make it very robust, just put the code in that I wanted. You made it so easy for me to use images for sidebox titles using the Image Titles mod that I decided to apply the same concept to my EZPages links. In case you ever choose to expand your Categories Dressing mod to include the EZ Pages sidebox, here's the code from my tpl_ezpages.php (it's the full code from 1.3.8a):

<?php
/**
 * Side Box Template
 *        05/28/08    Modifications adapted from Categories Dressing mod to post images instead of the
 *                            page name if the *.gif image is available. Also defines CSS id "ezLink" concatenated
 *                            with the same name as the EZ Link with blanks converted to underscores for the anchor tag
 *
 * @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: tpl_ezpages.php 2982 2006-02-07 07:56:41Z birdbrain $
 */
 
    $content = "";
    $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">';
    $content  .= "\n" . '<ul style="margin: 0; padding: 0; list-style-type: none;">' . "\n";
    for ($i=1, $n=sizeof($var_linksList); $i<=$n; $i++) { 
        $ez_name_display = $var_linksList[$i]['name'];
          $assoc_image_file = 'ezimg_' . strtr($ez_name_display,' ','_') . '.gif'; /* replace blanks in name with underscore */
          if( file_exists(DIR_WS_TEMPLATE_IMAGES . $assoc_image_file) ) {
              /* code has determined that image file with appropriate name exists, so plug it in */
              $ez_name_display = zen_image(DIR_WS_TEMPLATE_IMAGES . $assoc_image_file, '', '', '', ' title="Follow link to ' . $ez_name_display . ' "');
          }
        $content .= '<li><a href="' . $var_linksList[$i]['link'] . '">' . $ez_name_display . '</a></li>' . "\n" ;
    } // end FOR loop
    $content  .= '</ul>' . "\n";
    $content .= '</div>';
?>
```Hope this is helpful, Karen
28 May 2008, 20:08
#254
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Categories Dressing

Good work! Thanks for posting this so others can use it.
At a glance, it looks pretty complete to me. "Robust" doesn't mean having a lot of different features, just making the included features work in all circumstances.

28 May 2008, 20:16
#255
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Categories Dressing

It might be a good idea to post this in a new thread titled something like "Images for EZ-Page Links" so it will be easier for people to find.

29 May 2008, 02:07
#256
busymom avatar

busymom

New Zenner

Join Date:
Jul 2007
Posts:
61
Plugin Contributions:
0

Re: Categories Dressing

I don't actually know how to move a post! I also just realized that the code I posted doesn't have the CSS tag code in it, even though the header comments says it does. I'll have to edit that part of the comments out before I re-post. I did have the code in there but decided to pull it out - there are already so many different ways of changing the css for the ezpages sidebox that I decided it was overkill.

I'll dup the post at your suggestion.
Karen

29 May 2008, 14:21
#257
busymom avatar

busymom

New Zenner

Join Date:
Jul 2007
Posts:
61
Plugin Contributions:
0

Re: Categories Dressing

Didn't know appropriate place to post it, but I followed your advice, Glenn, and posted it here:

http://www.zen-cart.com/forum/showthread.php?t=98946

Thanks for giving me the code in both mods to make my work so much easier!! Karen

29 May 2008, 14:50
#258
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Categories Dressing

I just noticed a typo in one line:php $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">'; The closing ) is misplaced.```php
$content .= '<div id="' . str_replace('_', '-', $box_id) . 'Content" class="sideBoxContent">';

30 May 2008, 04:27
#259
busymom avatar

busymom

New Zenner

Join Date:
Jul 2007
Posts:
61
Plugin Contributions:
0

Re: Categories Dressing

gjh42:

I just noticed a typo in one line:php $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">'; The closing ) is misplaced.```php
$content .= '<div id="' . str_replace('_', '-', $box_id) . 'Content" class="sideBoxContent">';

Ironically, Glenn, I didn't change this code, it is still original from 1.3.8a. At first glance, I'd have to agree that it looks like a bug in the original code, though not one that I injected. Since I'm doing my development on my laptop and I'm on my desktop right now, I don't have any of my code in front of me, although I am looking at a vanilla unzipped version of 1.3.8a and the apparent oops is in there. 
 
... looking more carefully ...
 
Actually, the more I look at it, I don't think its a bug at all. If you look carefully, they are building the name of the div id, but they are replacing the underscores with dashes. The string 'Content' gets concatenated on to the $box_id as part of the name of the id (like sideBoxContent is the class name - notice the Content tacked onto the end of the name). If the code was changed the way you suggested, there would be an extra keyword 'Content' in the <div> declaration between the id and class attributes. I'm not sure if that would flag an error, but I'm pretty certain that 'Content' would be unrecognized.
 
Does that makes sense to you?
Karen
30 May 2008, 06:14
#260
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Categories Dressing

Actually either is fine and will generate the same result.

The str_replace function here is simply replacing underlines with hyphens and including the result in the DIV ID. Since the string Content doesn't have any hyphens, it's unchanged. Whether it's therefore included in the ID by the str_replace or added afterwards makes no difference, the end result.

Glenn's version is however, very slightly more efficient and would be the way that I would code it by default, since the code will execute a fraction of a millisecond quicker if the Content string is outside of the str_replace function as then it doesn't have to be checked to see if has any underscores.