kristopher
Joined: 24 Apr 2004 Posts: 2
|
Posted: Sat Apr 24, 2004 11:00 pm Post subject: Horizontal catagories |
|
|
Not sure if this is considered a hack or mod but I started using b2 today and wanted to have a horizontal catagory listing and searched through the forums but couldnt find anything except another person asking the same thing.
Anyhow I wanted to post this so if someone else who wants the same thing they may get use out of it.
I spent the better part of half a day working on this and finally got it working by taking the list_cats function out of the b2templates.functions.php and putting it into the index page.
Heres the edited code...
Code: | // out of the b2 loop
function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = 'blah') {
global $tablecategories,$querycount;
global $pagenow;
global $querystring_start, $querystring_equal, $querystring_separator;
$file = ($file == 'blah') ? $pagenow : $file;
$sort_column = 'cat_'.$sort_column;
$query="SELECT * FROM $tablecategories WHERE cat_ID > 0 ORDER BY $sort_column $sort_order";
$result=mysql_query($query);
$querycount++;
if (intval($optionall) == 1) {
$all = apply_filters('list_cats', $all);
echo "\t<a href=\"".$file.$querystring_start.'cat'.$querystring_equal.'all">'.$all."</a>\n";
}
while($row = mysql_fetch_object($result)) {
$cat_name = $row->cat_name;
$cat_name = apply_filters('list_cats', $cat_name);
echo "\t<a href=\"".$file.$querystring_start.'cat'.$querystring_equal.$row->cat_ID.'">';
echo stripslashes($cat_name)."</a>\n";
}
} |
All that you need to do is take out the <br /> like I did above and it'll be on the same line. Be sure you took out the code from the b2templates.functions.php and inserted it into the page you are calling the function from, if you dont then it the function gets defines (Dunno if thats the right terminology) twice and an parse error occurs.
Hope this helps |
|