Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Help with some coding pls

Mighty Mike

Recommended Posts

Hi All,


I hope you can help me out here, i have got to the stage where i am now in the deep end and cant swim anymore.


I wanted to achieve displaying the categories name in product_info, which i have done. But i do not have much control over how it is displayed.


What i did was to use the code from the all products file to do this and it works fine, but where i get stuck is this array stuff. To be honest i do not have a clue how it works or what i can do to change it.


this is the code i have so far

$inc_cat = array();
while ($included_categories = tep_db_fetch_array($included_categories_query)) {
 $inc_cat[] = array (
    'id' => $included_categories['categories_id'],
    'parent' => $included_categories['parent_id'],
    'name' => $included_categories['categories_name']);
$cat_info = array();
for ($i=0; $i<sizeof($inc_cat); $i++)
 $cat_info[$inc_cat[$i]['id']] = array (
   'parent'=> $inc_cat[$i]['parent'],
   'name'  => $inc_cat[$i]['name'],
   'path'  => $inc_cat[$i]['id'],
   'link'  => '' );

for ($i=0; $i<sizeof($inc_cat); $i++) {
 $cat_id = $inc_cat[$i]['id'];
 while ($cat_info[$cat_id]['parent'] != 0){
   $cat_info[$inc_cat[$i]['id']]['path'] = $cat_info[$cat_id]['parent'] . '_' . $cat_info[$inc_cat[$i]['id']]['path'];
   $cat_id = $cat_info[$cat_id]['parent'];
 $link_array = split('_', $cat_info[$inc_cat[$i]['id']] ['path']);
 for ($j=0; $j<sizeof($link_array); $j++) {
   $cat_info[$inc_cat[$i]['id']]['link'] .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $cat_info[$link_array[$j]]['path']) . '"><br />' . $cat_info[$link_array[$j]]['name'] . '</a>';


This is the display part

while($products = tep_db_fetch_array($product_info_query)) {
"          \n" .
(($memory == $products['categories_id'])? '': $cat_info[$products['categories_id']]['link']);
 $memory = $products['categories_id'];


Now at the moment it displays the info i need but for the life of me i cant change the display :blink:


Currently it displays like this


Category 1


Category 2


and in some cases i have a third level


Category 3


The only thing i have been able to do is put a <br> tag in :D


What i need it to do is display "Description: Cat 1" on its own, the "Description: Cat 2 & 3" on its own on the next line. Description being hard coded text or a define in the language file.


What i assume i need to do is build an array just for Cat 1 and then another for Cat 2 & 3. Is that correct? This is the point i am totally lost.


Or am i going about this the wrong way and there is another far easier way to do this?


Any help gratefully appreciated




Mike :thumbsup:

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...