Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How can I bring out the categories_htc_descriptions value from the query


ken0306

Recommended Posts

Posted

Hi, I trying to add extra info to my dropdown header. currently I using the cat_navbar.php for my categories list. Now I want to add the categories_htc_description from the categories table.

 

 

the query was

 

$result = tep_db_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 and cd.language_id="' . (int)$languages_id .'" '.$parent_query.'GROUP BY c.categories_id order by sort_order, cd.categories_name');

while ($row = tep_db_fetch_array($result)) {

 $table[$row['parent_id']][$row['categories_id']] = $row['categories_name'];


}

 

and I change to

 


$result = tep_db_query('select c.categories_id, cd.categories_name, cd.categories_htc_description, c.parent_id from ' . TABLE_CATEGORIES . ' c, ' . TABLE_CATEGORIES_DESCRIPTION . ' cd where c.categories_id = cd.categories_id and cd.language_id="' . (int)$languages_id .'" '.$parent_query.'GROUP BY c.categories_id order by sort_order, cd.categories_name');



while ($row = tep_db_fetch_array($result)) {

 $table[$row['parent_id']][$row['categories_id']] = $row['categories_name'];

$extra = $result['categories_htc_description'];
}

 

 

 

However, I can't get the categories_htc_description out of my page.

 

 

Here is my whole page for the cat_navbar.php

 

 

<?php
$show_full_tree = true;

// This is the CSS *ID* you want to assign to the UL (unordered list) containing
// your category menu. Used in conjuction with the CSS list you create for the menu.
// This value cannot be blank.
$idname_for_menu = 'sf-menu'; // see superfish.css


// This is the *CLASSNAME* you want to tag a LI to indicate the selected category.
// The currently selected category (and its parents, if any) will be tagged with
// this class. Modify your stylesheet as appropriate. Leave blank or set to false to not assign a class.
//gt $classname_for_selected = 'selected';
$classname_for_selected = 'current'; // see superfish.css


// This is the *CLASSNAME* you want to tag a LI to indicate a category has subcategores.
// Modify your stylesheet to draw an indicator to show the users that subcategories are
// available. Leave blank or set to false to not assign a class.
//gt $classname_for_parent = 'parent';
$classname_for_parent = 'parent_current'; //see superfish.css


// This is the HTML that you would like to appear before your categories menu
// This is useful for reconciling tables or clearing
// floats, depending on your layout needs. Leave blank for no html
$before_html = '
<div id="nav" class="top_nav">
<div class=" before_html "></div>
<div class="cat_navbar " id="navWrap">';

// This is the HTML that you would like to appear after your categories menu if *not*
// displaying in a standard "box". This is useful for reconciling tables or clearing
// floats, depending on your layout needs.
$after_html = '<div class=" after_html"></div>

 </div>
</div>
';

// END Configuration options
// Global Variables
$GLOBALS['this_level'] = 0;
// Initialize HTML and info_box class if displaying inside a box

// Generate a bulleted list (uses configuration options above)
$categories_string = tep_make_catsf_ullist();

echo $before_html;
echo $categories_string;
echo $after_html;
// Create the root unordered list
// function tep_make_catsf_ullist($rootcatid = 0, $maxlevel = 0){
// only dropdown second level
function tep_make_catsf_ullist($rootcatid = 0, $maxlevel = 2){
global $idname_for_menu, $cPath_array, $show_full_tree, $languages_id;
// Modify category query if not fetching all categories (limit to root cats and selected subcat tree)
if (!$show_full_tree) {
 $parent_query = 'AND (c.parent_id = "0"';

if (isset($cPath_array)) {

 $cPath_array_temp = $cPath_array;

 foreach($cPath_array_temp AS $key => $value) {
	 $parent_query .= ' OR c.parent_id = "'.$value.'"';
 }

 unset($cPath_array_temp);
}

 $parent_query .= ')';
} else {
 $parent_query = '';
}

$result = tep_db_query('select c.categories_id, cd.categories_name, cd.categories_htc_description, c.parent_id from ' . TABLE_CATEGORIES . ' c, ' . TABLE_CATEGORIES_DESCRIPTION . ' cd where c.categories_id = cd.categories_id and cd.language_id="' . (int)$languages_id .'" '.$parent_query.'GROUP BY c.categories_id order by sort_order, cd.categories_name');



while ($row = tep_db_fetch_array($result)) {

 $table[$row['parent_id']][$row['categories_id']] = $row['categories_name'];

$extra = $result['categories_htc_description'];
}

$output .= '<ul class="'.$idname_for_menu.'">';

//gt $output .= '<ul id="'.$idname_for_menu.'">';
$output .= tep_make_catsf_ulbranch($rootcatid, $table, 0, $maxlevel);

// Close off nested lists
for ($nest = 0; $nest <= $GLOBALS['this_level']; $nest++) {

//if you need extra links uncomment out the lines below
$output .= '

<li class="current_0 nav_registry" ><a href="' . tep_href_link(FILENAME_REGISTRY_SEARCH, '', 'NONSSL') . '">' . "" .LINK_BABY_REGISTRY . '</a></li>
 <li class="current_0 nav_brands" ><a href="' . tep_href_link(FILENAME_MANUFACTURERS, '', 'NONSSL') . '">' .LINK_SHOP_BY_BRAND . '</a></li>

 </ul></li>';
 $output .='


 ';

 $output .= '</ul>';
}

return $output;
}
// Create the branches of the unordered list
function tep_make_catsf_ulbranch($parcat, $table, $level, $maxlevel ) {
global $cPath_array, $classname_for_selected, $classname_for_parent;

$list = $table[$parcat];

while(list($key,$val) = each($list)){

 if ($GLOBALS['this_level'] != $level) {
	 if ($GLOBALS['this_level'] < $level) {
	 $output .= "\n".'<ul class="current_1"><dd class="custom_com">';
 } else {
		 for ($nest = 1; $nest <= ($GLOBALS['this_level'] - $level); $nest++) {

			 $output .= '<dt>extra '. $extra .' info</dt></dd></ul>'."\n";
		 }
/*	
 if ($GLOBALS['this_level'] -1 == $level)
$output .= '</ul></li>'."\n";
elseif ($GLOBALS['this_level'] -2 == $level)
$output .= '</ul></li></ul></li>'."\n";
elseif ($GLOBALS['this_level'] -3 == $level)
$output .= '</ul></li></ul></li></ul></li>'."\n";
elseif ($GLOBALS['this_level'] -4 == $level)
$output .= '</ul></li></ul></li></ul></li></ul></li>'."\n";
*/	
 }

	 $GLOBALS['this_level'] = $level;
 }
 if (isset($cPath_array) && in_array($key, $cPath_array) && $classname_for_selected) {
	 $this_cat_class = ' class="'.$classname_for_selected.'"';
 } else {
	 $this_cat_class = '';
 }

 //gt $output .= '<li class="cat_lev_'.$level.'"><a href="';
	 $output .= '<li class="current_'.$level.'"><a href="';
 if (!$level) {
 unset($GLOBALS['cPath_set']);
 $GLOBALS['cPath_set'][0] = $key;
	 $cPath_new = 'cPath=' . $key;
 } else {
 $GLOBALS['cPath_set'][$level] = $key;
	 $cPath_new = 'cPath=' . implode("_", array_slice($GLOBALS['cPath_set'], 0, ($level+1)));
 }

 if (tep_has_category_subcategories($key) && $classname_for_parent) {
	 $this_parent_class = ' class="'.$classname_for_parent.'"';
 } else {
	 $this_parent_class = ' class="current_1_top1"';
 }
 $output .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '"'.$this_parent_class.'>'.$val;
 if (SHOW_COUNTS == 'true') {
	 $products_in_category = tep_count_products_in_category($key);
	 if ($products_in_category > 0) {
		 $output .= ' (' . $products_in_category . ')';
	 }
 }

 $output .= '</a>';
 if (!tep_has_category_subcategories($key)) {
	 $output .= '</li>'."\n";
 }	

 if ((isset($table[$key])) AND (($maxlevel > $level + 1) OR ($maxlevel == '0'))) {
	 $output .= tep_make_catsf_ulbranch($key,$table,$level + 1,$maxlevel);




 }

} // End while loop
return $output;

}

?>

 

 

$extra is the value that I trying to define and hack in to my drop-down category nav.

 

thank you for you help

ken

Posted

Change the extra line so it looks pretty much like the $tabel line

while ($row = tep_db_fetch_array($result)) {

        $table[$row['parent_id']][$row['categories_id']] = $row['categories_name'];
        $extra[$row['parent_id']][$row['categories_id']] = $row['categories_htc_description'];
}

 

Now to retrieve/show the categories_htc_description, do like it is done for the name, but replace $table with $extra

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Posted

Change the extra line so it looks pretty much like the $tabel line

while ($row = tep_db_fetch_array($result)) {

$table[$row['parent_id']][$row['categories_id']] = $row['categories_name'];
$extra[$row['parent_id']][$row['categories_id']] = $row['categories_htc_description'];
}

 

Now to retrieve/show the categories_htc_description, do like it is done for the name, but replace $table with $extra

 

 

Hi, thank you for taking time to look at it.

 

But the categories_htc_description information doesn't shows up.

 

so I change the code as you said from

 

while ($row = tep_db_fetch_array($result)) {	

 $table[$row['parent_id']][$row['categories_id']] = $row['categories_name'];

}

 

 

to

 

 

 

while ($row = tep_db_fetch_array($result)) {

 $table[$row['parent_id']][$row['categories_id']] = $row['categories_name'];
$extra[$row['parent_id']][$row['categories_id']] = $row['categories_htc_description'];

}

 

 

and change the code that will shows the categories drop down from

// Create the branches of the unordered list
function tep_make_catsf_ulbranch($parcat, $table, $level, $maxlevel ) {
global $cPath_array, $classname_for_selected, $classname_for_parent;

$list = $table[$parcat];


while(list($key,$val) = each($list)){

 if ($GLOBALS['this_level'] != $level) {
	 if ($GLOBALS['this_level'] < $level) {
	 $output .= "\n".'<ul class="current_1">';
 } else {
		 for ($nest = 1; $nest <= ($GLOBALS['this_level'] - $level); $nest++) {

			 $output .= '</ul>'."\n";
		 }

 }

	 $GLOBALS['this_level'] = $level;
 }

 

to

 

// Create the branches of the unordered list
function tep_make_catsf_ulbranch($parcat, $table, $level, $maxlevel, $extra ) {
global $cPath_array, $classname_for_selected, $classname_for_parent;

$list = $table[$parcat];


while(list($key,$val) = each($list)){

 if ($GLOBALS['this_level'] != $level) {
	 if ($GLOBALS['this_level'] < $level) {
	 $output .= "\n".'<ul class="current_1"><dd class="custom_com">';
 } else {
		 for ($nest = 1; $nest <= ($GLOBALS['this_level'] - $level); $nest++) {

			 $output .= '<dt>extra '. $extra .' info</dt></dd></ul>'."\n";
		 }

 }

 

 

But it still not loading the categories_htc_description information from the database.

 

Which part that I did it wrong?

 

Thank you.

ken

Posted

maybe missing the point here but your cat description will surely be added from the index.php so would search there for the query about line 60 - 70

 

When using the cat navbar I seen it more as a module / box which I never need to change to get a cat desc as regards header tags /meta etc but maybe got the wrong end of the stick here??

To improve is to change; to be perfect is to change often.

 

Posted

just before show_counts == true the categories name is shown by outputting $val

 

I think you can retrieve the corresponding extra info at that point as

$extra[$parcat][$key]

 

or perhaps you first need to do something like

$extralist = $extra[$parcat]; //before the while loop

$htcdesc = $extralist[$key]; //within the while loop as it changes for each category

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Posted

@@joli1811

 

he wants it included in the megamenu on top.

I would love to see this working too, I also use the cat_navbar, would be nice if some description could be added for some categories ...

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Posted

maybe missing the point here but your cat description will surely be added from the index.php so would search there for the query about line 60 - 70

 

When using the cat navbar I seen it more as a module / box which I never need to change to get a cat desc as regards header tags /meta etc but maybe got the wrong end of the stick here??

 

Hi Joli

 

Here is what I trying to do.

 

post-43239-0-88167200-1390007439_thumb.jpg

 

I trying to adding extra option to the navbar, and allow me to insert the custom html promotions info to the nav dropdown. the reason I using the categories_htc_description is because the file already under categories_description table, and I don't have to worry about language or join table issues.

 

ken

Posted

@@joli1811

 

he wants it included in the megamenu on top.

I would love to see this working too, I also use the cat_navbar, would be nice if some description could be added for some categories ...

 

Trying to do for ages :) --> HERE this is a hybird from mega menu and superfish but the code mainly css is not really suitable for release needs cleaned up

 

Actually a hybrid from mega menu (think it was the word press one can search for the link ) and the super fish to displays the cats.

 

It was as much as I could do to get it work dynamically with the products / categories and manufacture ( did have pics display not dynamic but got lost in the css ) maybe try again

 

@@Tsimi done a bit of work and got more of the mega feel but was not dynamic here

 

I think it should be possible to pull in a mini description and maybe a image maybe more a lot of css work than the code to get it to display

 

It would be difficult

 

Regards

Joli

 

 

 

Well the code above is more of a box so the link example above has for example the cat desc from header tags reloaded can not see any difference when using header tags seo

 

I did misunderstand thougt this was more about Meta tags etc.....

 

Quite welcome to have the code that I have but not it is not ideal I used the unordered list which is the code below

 

http://addons.oscommerce.com/info/4201

To improve is to change; to be perfect is to change often.

 

Posted

you can basically add anything inside a superfish mega menu if you have the coding skills to do it. that is where i failed.

you can sure add a short categories description and/or output anything else inside the mega menu tab. hard coded is very easy to do

but dynamically is quite tricky.

 

wordpress plugins

 

http://wpmegamenu.com/

Posted

just before show_counts == true the categories name is shown by outputting $val

 

I think you can retrieve the corresponding extra info at that point as

$extra[$parcat][$key]

 

or perhaps you first need to do something like

$extralist = $extra[$parcat]; //before the while loop

$htcdesc = $extralist[$key]; //within the while loop as it changes for each category

 

I think I find an alternative way to display a drop down to make the mega drop header. :). let me see if I can make it happen or not, and get it back tomorrow.

Posted

Finally, I find the way to break it.

 

First, change

 

$result = tep_db_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 and cd.language_id="' . (int)$languages_id .'" '.$parent_query.'order by sort_order, cd.categories_name');

while ($row = tep_db_fetch_array($result)) {        

    $table[$row['parent_id']][$row['categories_id']] = $row['categories_name'];

}


 

to

 

 

$result = tep_db_query('select c.categories_id, cd.categories_name, cd.categories_htc_description, c.parent_id from ' . TABLE_CATEGORIES . ' c, ' . TABLE_CATEGORIES_DESCRIPTION . ' cd where c.categories_id = cd.categories_id and cd.language_id="' . (int)$languages_id .'" '.$parent_query.'order by sort_order, cd.categories_name');

while ($row = tep_db_fetch_array($result)) {        

    $table[$row['parent_id']][$row['categories_id']] = $row['categories_name'] .
       '</a>' .
        $row['categories_htc_description'];
   }

 

 

Second

 

 

 

Find

 


$output .= '</a>';   


    if (!tep_has_category_subcategories($key)) {
	    $output .= '</li>'."\n";   


 

 

change to

 

 

 


$output .= '';    

    if (!tep_has_category_subcategories($key)) {
	    $output .= '</li>'."\n";    
    }   	



 

 

Now we can using the categories_htc_description to insert our custom html. The rest will be dependent on your css skill to custom make your mega dropdown. :lol:

 

 

ken

Archived

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

×
×
  • Create New...