Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Forced Line Breaks in cateogry sidebox modules

Forced Line Breaks in cateogry sidebox modules

Locked

Views: 643

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
29 Jan 2009, 4:57 PM
#1
tootricky avatar

tootricky

New Zenner

Join Date:
Jan 2009
Posts:
4
Plugin Contributions:
0

Forced Line Breaks in cateogry sidebox modules

Hi,

I would like to add a line break to the category links in the sideboxes, so that every 4 links the script generates an extra <br> in the code. i.e instead of:

blue widgets
pink widgets
green widgets
yellow widgets
orange widgets
purple widgets
red widgets
turquoiuse widgets

you would have:

blue widgets
pink widgets
green widgets
yellow widgets

orange widgets
purple widgets
red widgets
turquoiuse widgets

and so on. I believe I have to do something to this portion of the code in tpl_categories, but it is beyond my knowldege of PHP:

 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']) . '" title="' . $box_categories_array[$i]['name'] . '">';

      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";
    }
  }

Can anybody offer a fellow zenner any assistance? :)

Thanks

29 Jan 2009, 6:37 PM
#2
bunyip avatar

bunyip

Totally Zenned

Join Date:
Sep 2004
Location:
Western Massachusetts
Posts:
2,361
Plugin Contributions:
1

Re: Forced Line Breaks in cateogry sidebox modules

It's pretty simple to just add a counter and get an extra line break.

In an override copy of tpl_categories.php, add a link counter variable after the first $content line so your code looks like this:

$content = "";
$linkcounter = 0;

Then further down the page, just before this line:

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

add this section of code

 $linkcounter++;
    if ($linkcounter == 4) {
     $content .= '<br />' . "\n";
     $linkcounter = 0;
    }

That will add a line break after 4 links and reset the counter.

Neville
An assumption is what you arrive at when you get tired of thinking...

29 Jan 2009, 9:27 PM
#3
tootricky avatar

tootricky

New Zenner

Join Date:
Jan 2009
Posts:
4
Plugin Contributions:
0

Re: Forced Line Breaks in cateogry sidebox modules

Thank you. I had already tried something similar using modulus, but I will try what you suggest. Thanks!