Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2009
    Posts
    4
    Plugin Contributions
    0

    Default 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:

    Code:
     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

  2. #2
    Join Date
    Sep 2004
    Location
    Western Massachusetts
    Posts
    2,945
    Plugin Contributions
    5

    Default 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:
    Code:
     $content = "";
     $linkcounter = 0;
    Then further down the page, just before this line:
    Code:
    $content .= '<br />' . "\n";
    add this section of code
    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...

  3. #3
    Join Date
    Jan 2009
    Posts
    4
    Plugin Contributions
    0

    Default 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!

 

 

Similar Threads

  1. Replies: 17
    Last Post: 12 Oct 2010, 05:58 PM
  2. Line Breaks ??
    By evil turinp in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 3 Feb 2010, 12:07 PM
  3. Line breaks in categories box
    By besheer in forum General Questions
    Replies: 2
    Last Post: 17 May 2006, 07:33 PM

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