boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Horizontal catagories

 
Post new topic   Reply to topic    boardom Forum Index -> Hacks
View previous topic :: View next topic  
Author Message
kristopher



Joined: 24 Apr 2004
Posts: 2

PostPosted: Sat Apr 24, 2004 11:00 pm    Post subject: Horizontal catagories Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> Hacks All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group