Go Back   Pligg Forum > Pligg Help > General Help
Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-04-2007, 08:40 AM
sunstardude sunstardude is offline
Casual Pligger
 
Join Date: May 2007
Posts: 36
Downloads: 7
Uploads: 0
Thanks: 1
Thanked 0 Times in 0 Posts
Question Category dropdown menu?

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
Sponsored Links
  #2 (permalink)  
Old 06-04-2007, 09:15 PM
allenp's Avatar
allenp allenp is offline
New Pligger
 
Join Date: Jun 2007
Posts: 6
Downloads: 0
Uploads: 0
Thanks: 0
Thanked 0 Times in 0 Posts
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, 07:12 AM
sunstardude sunstardude is offline
Casual Pligger
 
Join Date: May 2007
Posts: 36
Downloads: 7
Uploads: 0
Thanks: 1
Thanked 0 Times in 0 Posts
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
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Similar Threads
Thread Thread Starter Forum Replies Last Post
bold the main category, but unbold the subcategory? abcdefgary Pligg Templates 11 01-28-2008 04:15 PM
strories number in category menu diablo Pligg Mods 1 04-04-2007 07:15 AM
[Fixed] Ampersand (&) in Category name shows All Biomech Bug Report 5 03-16-2007 06:02 PM
new category code - improvements? cruci Pligg Mods 4 01-06-2007 12:35 PM
editlink.php show category id not category name fwebz Bug Report 0 01-28-2006 11:14 AM


LinkBacks Enabled by vBSEO 3.0.0