Category dropdown menu?

Register an Account
Pligg Chat Room
Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-04-2007, 09:40 AM
Casual Pligger
 
Join Date: May 2007
Posts: 30
What's the best way to make a dropdown menu that auto populates with the categories from the database, and also if possible maintain via a cookie or user-login whatever category user last selected. Any such code already made for pligg 9.5/6??
Reply With Quote
  #2 (permalink)  
Old 06-04-2007, 10:15 PM
allenp's Avatar
New Pligger
 
Join Date: Jun 2007
Posts: 5
To make a pulldown with the categories use the following php:

PHP Code:
        $catsql mysql_query("SELECT category_id, category_name FROM " table_categories " WHERE category_lang='$dblang' ORDER BY category_name ASC");
    
$categories = array();
    while (
$rows mysql_fetch_array ($catsqlMYSQL_ASSOC)) array_push ($categories$rows);
    
$main_smarty->assign('categories'$categories);

    include_once(
mnminclude.'dbtree.php');
    
$array tree_to_array(0table_categoriesFALSE);
    
$main_smarty->assign('lastspacer'0);
    
$main_smarty->assign('cat_array'$array); 
And this in the template:

PHP Code:
            <select name="category">
            {
section name=thecat loop=$cat_array}
               <
option value "{$cat_array[thecat].auto_id}">
                  {if 
$cat_array[thecat].spacercount lt $lastspacer}{$cat_array[thecat].spacerdiff|repeat_count:''}{/if}
                  {if 
$cat_array[thecat].spacercount gt $lastspacer}{/if}
                  {
$cat_array[thecat].spacercount|repeat_count:'&nbsp;&nbsp;&nbsp;'}
                  {
$cat_array[thecat].name
                  &
nbsp;&nbsp;&nbsp;       
                  {
assign var=lastspacer value=$cat_array[thecat].spacercount}
              </
option>
            {/
section}
        </
select
This is in submit.php and submit_step_2.tpl in the yget template if you want to see it in use.

Patrick
Reply With Quote
  #3 (permalink)  
Old 06-07-2007, 08:12 AM
Casual Pligger
 
Join Date: May 2007
Posts: 30
Thanks for the code, Patrick. But where do I put the PHP code? When I put it into the template with the other code it displays on the webpage as if it has not been processed.

Also, how do I make the dropdown menu go to selected category upon selection.. without having to hit a "submit" button?
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Control of meta description - categories Divisive Cotton Questions and Comments 65 11-06-2009 07:10 PM
Pligg Categories Yankidank Wiki Articles 1 12-17-2008 10:10 AM
How to show category keywords as text on the site? gnalkit Questions and Comments 4 11-26-2008 05:17 AM
Dropdown menu for categories (digg style) skroeger Questions and Comments 8 05-11-2008 05:43 PM
How to get a dropdown menu for subcategories ? jedimaster Questions and Comments 3 04-04-2008 04:28 PM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development