Results 1 to 3 of 3
  1. #1
    Casual Pligger sunstardude's Avatar
    Joined
    May 2007
    Posts
    30
    Thanks
    Received:0
    Given: 0

    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??

  2. #2
    New Pligger allenp's Avatar
    Joined
    Jun 2007
    Posts
    5
    Thanks
    Received:0
    Given: 0
    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

  3. #3
    Casual Pligger sunstardude's Avatar
    Joined
    May 2007
    Posts
    30
    Thanks
    Received:0
    Given: 0
    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?

Similar Threads

  1. Remove 'Category' dropdown menu from submit step 2
    By rethomas07 in forum Questions & Comments
    Replies: 2
    Last Post: 05-03-2011, 07:48 PM
  2. Adding dropdown menu to upload module
    By darkremixx in forum Questions & Comments
    Replies: 1
    Last Post: 03-03-2010, 10:26 AM
  3. Anynone can make the dropdown like digg menu header? I will pay
    By micxuy in forum Questions & Comments
    Replies: 6
    Last Post: 06-20-2008, 02:52 PM
  4. Dropdown menu for categories (digg style)
    By skroeger in forum Questions & Comments
    Replies: 8
    Last Post: 05-11-2008, 02:43 PM
  5. How to get a dropdown menu for subcategories ?
    By jedimaster in forum Questions & Comments
    Replies: 3
    Last Post: 04-04-2008, 01:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Pligg Modules and Pligg Templates from Pligg Pro Web Hosting Services by Midphase Dreamhost Web Hosting Donate to Pligg