Support Forums

How To: Vertical Menus (non JS)?

This is a discussion on How To: Vertical Menus (non JS)? within the Pre Sales Questions forums, part of the Pre-Sales & Testimonials category; Great looking site, and great idea to display your categories this way!...


Go Back   68 Classifieds Forums > Pre-Sales & Testimonials > Pre Sales Questions

Reply
 
Thread Tools Display Modes
Old 01-19-2007, 04:47 PM   #21
Senior Member
 
civ's Avatar
 
Join Date: Mar 2006
Location: Greer, SC
Posts: 601
Rep Power: 29
civ will become famous soon enough
Default

Great looking site, and great idea to display your categories this way!
__________________
Civ's Modules (____NOW v4 COMPATIBLE____):

Stop Incomplete Listings! (proven revenue booster!)
Scam Filter (Just say no to Nigerians!) updated
Similar Listings (keep visitors longer)
Feedback Mod (testimonial builder)
Listing Status Reminder free!
civ is offline   Reply With Quote
Old 01-19-2007, 05:01 PM   #22
Junior Member
 
 
Join Date: Jan 2007
Posts: 19
Rep Power: 14
dawnrae is on a distinguished road
Default

Thanks! Eric did the hard part, though ... he made my menu work with his magical skills!

Dawn
dawnrae is offline   Reply With Quote
Old 02-26-2007, 07:29 AM   #23
Just get on with it!
 
michael's Avatar
 
Join Date: Jan 2007
Location: Milton Keynes, England
Posts: 447
Rep Power: 27
michael is just really nice michael is just really nice
Default

Excellent! One question though. What if listings are nested at various depths according to the category they are in?

e.g.

Motors
>Vans
>Ford
>Transit

and

Pets
>Rabbits
__________________
M Michael
V4.1.9 Developer - Modified 3 Column Default Template


"All truths are easy to understand once they are discovered; the point is to discover them" - Galileo Galilei (1564 - 1642)
michael is offline   Reply With Quote
Old 05-12-2008, 03:53 PM   #24
Member
 
Join Date: May 2008
Posts: 88
Rep Power: 9
ombre is on a distinguished road
Smile

Quote:
Originally Posted by dawnrae
For anyone else who wishes a vertical menu in a similar fashion, here's the final code (many, many thanks to Eric).

function getTotal($cat)
{
global $db;
$sSQL="SELECT COUNT(*) AS total FROM ".PREFIX."listings WHERE display = 'Y' AND expiration > NOW() AND section=".$cat;
$result=$db->query($sSQL);
$row = $result->fetch();
return $row['total'];
}
?>
This is now bugfixed getTotal function the products table is changed to listings so we must query the listings table.

Regards, and thanks for this function. Great work boys
__________________
Version 4.0.9 - now live with 40.000 ads
ombre is offline   Reply With Quote
Old 05-20-2008, 01:50 PM   #25
Member
 
Join Date: Aug 2006
Location: UK
Posts: 46
Rep Power: 15
Red is on a distinguished road
Default

I've got this nearly working.
The menu shows, but there's no count, and when a category is selected it opens the category.php and not the actual single category id.

View here http://thebikemart.com/index.php

TIA


Fixed Problem!
__________________

Testing TheBikeMart at TheBikeMart.com
:: V4 Developer

Last edited by Red; 05-20-2008 at 05:12 PM.
Red is offline   Reply With Quote
Old 08-17-2008, 09:59 AM   #26
Senior Member
 
hel68c's Avatar
 
Join Date: Jun 2008
Location: Canada, Quebec
Posts: 284
Rep Power: 16
hel68c is just really nice hel68c is just really nice
Default Level 2 Sub category

Nice function,

but how to display level2 subcategory in categories?

category-->sub1-->sub2

Radio_Control-->Plane-->engine
__________________
Serge
HobbyClassified.com
V4.08 Developper, Module installed (CIV Scam Filter, Maffo Location System, Maffo News,Youtube, Seller Store)
hel68c is offline   Reply With Quote
Old 08-17-2008, 06:52 PM   #27
Senior Member
 
hel68c's Avatar
 
Join Date: Jun 2008
Location: Canada, Quebec
Posts: 284
Rep Power: 16
hel68c is just really nice hel68c is just really nice
Default

Nobody has an idea?
__________________
Serge
HobbyClassified.com
V4.08 Developper, Module installed (CIV Scam Filter, Maffo Location System, Maffo News,Youtube, Seller Store)
hel68c is offline   Reply With Quote
Old 08-18-2008, 09:04 AM   #28
Senior Member
 
hel68c's Avatar
 
Join Date: Jun 2008
Location: Canada, Quebec
Posts: 284
Rep Power: 16
hel68c is just really nice hel68c is just really nice
Default Level 2 Sub category

I found how to make a second level of sub category.

Category (9)
-->level1_sub_category (5)
-->-->level2_sub_category (4)

Here is my contribution to help.

Quote:
<?php
/**
* smarty_function_categories_ul
*
* This function is useful for using your categories in the navigation.
*
* All source code & content (c) Copyright 2006, 68 Classifieds
* unless specifically noted otherwise.
*
* @package 68classifieds
* @author Eric Barnes
* @copyright 68 Classifieds
* @link http://www.68classifieds.com
* @$Revision: 1.1 $
* @Updated: $Date: 2007/01/08 19:12:22 $
*/

function smarty_function_categories_ul($params, &$smarty)
{
global $db;

$ul_attr = '';
$li_attr = '';
$depth=2;
$show_total = 'Y';

foreach ($params as $_key=>$_value)
{
switch ($_key)
{
case 'depth':
$$_key = (int)$_value;
break;

case 'ul_attr':
case 'li_attr':
case 'show_total':
$$_key = (string)$_value;
break;
}
}

$sSQL="SELECT id,name,parent_id,cOrder,cLink,slug FROM ".PREFIX."categories WHERE parent_id=0 AND display<>'N' ORDER BY cORDER DESC, name ASC";
$result=$db->query($sSQL);
$output="<ul ".$ul_attr.">\n";
while($row = $result->fetch())
{
$slug=$row['slug'];
$id=$row['id'];
$parent=$row['parent_id'];
if($row['cLink']<>'')
{
$link=$row['cLink'];
}
else
{
$link='category.php?cat='.$slug;
}
$output .= "<strong><li ".$li_attr."><a href=\"".$link."\">".$row['name']."</strong></a>\n";
if($show_total=='Y')
{
$arr_childs='';
$arr_childs = array($id);
get_cat_ids($arr_childs);
$total=get_cat_count($arr_childs);
$output.="( ". $total .")";
}
//get sub categories
$sSQL2="SELECT id,name,parent_id,cOrder,cLink,slug FROM ".PREFIX."categories WHERE parent_id=".$id." AND display<>'N' ORDER BY cORDER DESC, name ASC";
//$output.=$sSQL2."\n";
$result2=$db->query($sSQL2);
if($result2->size() > 0)
{
$output.="<ul>\n";
while($row = $result2->fetch())
{
$slug=$row['slug'];
$subid=$row['id'];
if($row['cLink']<>'')
{
$link=$row['cLink'];
}
else
{
if($subid>1)
{
$link='category.php?cat='.$slug;
}
else
{
$link='category.php?cat='.$slug;
}
}
$output .= "<li ".$li_attr."><a href=\"".$link."\">-->".$row['name']."</a>\n";
if($show_total=='Y') {
$arr_childs='';
$arr_childs = array($subid);
get_cat_ids($arr_childs);
$total=get_cat_count($arr_childs);
$output.="( ". $total .")";

}

//get sub_sub categories
$sSQL3="SELECT id,name,parent_id,cOrder,cLink,slug FROM ".PREFIX."categories WHERE parent_id=".$subid." AND display<>'N' ORDER BY cORDER DESC, name ASC";
$result3=$db->query($sSQL3);
if($result3->size() > 0)
{
$output.="<ul>\n";
while($row = $result3->fetch())
{
$slug=$row['slug'];
$sub_subid=$row['id'];
if($row['cLink']<>'')
{
$link=$row['cLink'];
}
else
{
if($sub_subid>1)
{
$link='category.php?cat='.$slug;
}
else
{
$link='category.php?cat='.$slug;
}
}
$output .= "<li ".$li_attr."><a href=\"".$link."\">-->-->".$row['name']."</a>\n";
if($show_total=='Y')
{
$arr_childs='';
$arr_childs = array($sub_subid);
get_cat_ids($arr_childs);
$total=get_cat_count($arr_childs);
$output.="( ". $total .")";
}
}
$output.="</ul>\n";
}
$output.="</li>\n";


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

function get_cat_ids($arr_ids)
{
$arr_new= array();
global $arr_childs, $db;
$sSQL="SELECT id FROM ".PREFIX."categories WHERE parent_id In (". implode(', ', $arr_ids) .")";
$result=$db->query($sSQL);
if($result->size() >= '1')
{
while($rs=$result->fetch())
{
if (!in_array($rs['id'], $arr_childs))
{
$arr_childs[] = $rs['id'];
$arr_new[] = $rs['id'];
}
}
if (count($arr_new) >= '1')
{
get_cat_ids($arr_new);
}
else
{
return;
}

}
else
{
return;
}
}
function get_cat_count($arr_ids)
{
global $db, $modules;
$sSQL="SELECT COUNT(*) AS size FROM ".PREFIX."listings WHERE ".$where." section In (". implode(', ', $arr_ids) .") AND expiration > NOW() AND (display='Y' OR display='S')";
$result=$db->query($sSQL);
$row = $result->fetch();
$total=$row['size'];
return $total;
}
/*
//get sub_sub categories
$sSQL3="SELECT id,name,parent_id,cOrder,cLink,slug FROM ".PREFIX."categories WHERE parent_id=".$subid." AND display<>'N' ORDER BY cORDER DESC, name ASC";
$result3=$db->query($sSQL3);
if($result3->size() > 0)
{
$output.="<ul>\n";
while($row = $result3->fetch())
{
$slug=$row['slug'];
$sub_subid=$row['id'];
if($row['cLink']<>'')
{
$link=$row['cLink'];
}
else
{
if($sub_subid>1)
{
$link='category.php?cat='.$slug;
}
else
{
$link='category.php?cat='.$slug;
}
}
$output .= "<li ".$li_attr."><a href=\"".$link."\">".$row['name']."</a>\n";
if($show_total=='Y')
{
$arr_childs='';
$arr_childs = array($sub_subid);
get_cat_ids($arr_childs);
$total=get_cat_count($arr_childs);
$output.="( ". $total .")";
}
}
$output.="</ul>\n";
}
$output.="</li>\n"; */



?>
__________________
Serge
HobbyClassified.com
V4.08 Developper, Module installed (CIV Scam Filter, Maffo Location System, Maffo News,Youtube, Seller Store)

Last edited by hel68c; 08-18-2008 at 09:08 AM.
hel68c is offline   Reply With Quote
Old 08-18-2008, 11:18 AM   #29
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,401
Rep Power: 128
Eric Barnes is just really nice Eric Barnes is just really nice
Default

Hi,

Thanks for sharing. You may want to post this as a new topic in the module release section so other people can find it.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Reply

Tags
None

Thread Tools
Display Modes



All times are GMT -4. The time now is 10:46 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17