osCommerce and osCMax shopping cart software forums

Shopping Cart Software

osCommerce with teeth!

 
 

Categories box layout nightmare Need Help!

This is a discussion on Categories box layout nightmare Need Help! within the osCommerce 2.2 Modification Help forums, part of the osCommerce 2.2 Forums category; I've been at this for the past week. I thought it would be very simple But I as it turns ...


Go Back   osCommerce and osCMax shopping cart software forums > osCommerce 2.2 Forums > osCommerce 2.2 Modification Help

Register FAQ Members List Calendar Mark Forums Read


Free community membership! Fast easy FREE membership
Closed Thread

 

LinkBack Thread Tools
  #1  
Old 04-25-2003, 01:49 PM
Lurker
 
Join Date: Dec 2002
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
magder
Default Categories box layout nightmare Need Help!

I've been at this for the past week. I thought it would be very simple But I as it turns out, I'm very simple.

In the categories box I want to show Top categories and the sub categories beneath it. I want to have conrtrol with css over both the category and the subcategories so they look different.

Something Like this:

Books
  • subcat book 1
    subcat book 2
    subcat book 3

Audio Tapes
  • subcatTape 1
    subcatTape 2
    subcatTape3

I found a contribution called all categories by Christian Lescuyer which allowed me to list cats and subcats underneath. However I can't figure out how to separate them to achieve the above look.

The all categories code looks like this:

Code:
// Preorder tree traversal
  function preorder($cid, $level, $foo, $cpath)
  {
    global $categories_string, $HTTP_GET_VARS;

// Display link
    if ($cid != 0) {
      for ($i=0; $i<$level; $i++)
        $categories_string .=  '&&';
      $categories_string .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $cpath . $cid) . '">';
// 1.6 Are we on the "path" to selected category?
      $bold = strstr($HTTP_GET_VARS['cPath'], $cpath . $cid . '_') || $HTTP_GET_VARS['cPath'] == $cpath . $cid;
// 1.6 If yes, use <b>
      if ($bold)
        $categories_string .=  '<b>';
      $categories_string .=  $foo[$cid]['name'];
      if ($bold)
        $categories_string .=  '</b>';
      $categories_string .=  '</a>';
// 1.4 SHOW_COUNTS is 'true' or 'false', not true or false
      if (SHOW_COUNTS == 'true') {
        $products_in_category = tep_count_products_in_category($cid);
        if ($products_in_category > 0) {
          $categories_string .= '&(' . $products_in_category . ')';
        }
      }
      $categories_string .= '<br>';
    }

// Traverse category tree
    foreach ($foo as $key => $value) {
      if ($foo[$key]['parent'] == $cid) {
//        print "$key, $level, $cid, $cpath<br>";
        preorder($key, $level+1, $foo, ($level != 0 ? $cpath . $cid . '_' : ''));
      }
    }
  }

?>
<!-- all_categories //-->
          <tr>
            <td>
<?php
//////////
// Display box heading
//////////
  $info_box_contents = array();
  $info_box_contents[] = array('align' => 'left', 'text'  => BOX_HEADING_CATEGORIES);
  new infoBoxHeading($info_box_contents, true, false);


//////////
// Get categories list
//////////
// 1.2 Test for presence of status field for compatibility with older versions
  $status = tep_db_num_rows(tep_db_query('describe categories status'));

  $query = "select c.categories_id, cd.categories_name, c.parent_id
            from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
            where c.categories_id = cd.categories_id";
// 1.3 Can't have 'where' in an if statement!
  if ($status >0)
    $query.= " and c.status = '1'";
  $query.= " and cd.language_id='" . $languages_id ."'
            order by sort_order, cd.categories_name";

  $categories_query = tep_db_query($query);

// Stuff in an array
  while ($categories = tep_db_fetch_array($categories_query))  {
    $foo[$categories['categories_id']] = array('name' => $categories['categories_name'], 'parent' => $categories['parent_id']);
  }

// Initiate tree traverse
  $categories_string = '';
  preorder(0, 0, $foo, '');

//////////
// Display box contents
//////////
  $info_box_contents = array();
  $info_box_contents[] = array('align' => 'left', 'text'  => $categories_string);
  new infoBox($info_box_contents);
?>
            </td>
          </tr>
<!-- all_categories_eof //-->
Christian offered this help via email but have not been able to make it work.


Code:
You have to do it at build time, in the preorder() function.
Locate:
if ($bold)

  $categories_string .= '<b>';

Add something like:
if ($level == 0) 

  $categories_string .= '<span class="whatever">';

Then after the name and before the second "bold" thing, close the tag:

if ($level == 0) 

  $categories_string .= '</span>';
I've slept very little and I'm eating a lot. I'm having a store layout depression.

Any help would be more than apreciated and most certainly compensated .

Gary
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Sponsored Links
Advertisement
  #2  
Old 02-25-2004, 11:18 AM
Lurker
 
Join Date: Jan 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
sinisnap
Default

yeah i agree, it would be awesome to have a solution to this...gary did you ever figure it out??
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #3  
Old 02-25-2004, 12:12 PM
Lurker
 
Join Date: Dec 2002
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
magder
Default

No I never did figure it out. I just started using the abbox store the templating system and hope I can do i there.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Sponsored Links
Advertisement
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Diagram of layout? doggerwatson osCommerce 2.2 Modification Help 1 09-22-2004 07:30 AM
layout questions choyt3 osCommerce 2.2 Modification Help 2 05-20-2004 01:27 PM
layout in productlisting? amilo osCMax v1.7 Discussion 3 05-17-2004 02:05 PM
Layout with transparent gifs vs. layout with CSS Lynoure osCommerce 2.2 Modification Help 1 01-16-2004 02:22 AM
Layout questions-help.... whazzy osCommerce 2.2 Modification Help 1 10-30-2003 12:38 PM


All times are GMT -8. The time now is 07:42 PM.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO
http://www.oscmax.com/forums/
Copyright 2008 osCMax