Results 1 to 14 of 14

Thread: How to: Drop down menu for instant jump to category?

  1. #1
    Join Date
    Jul 2006
    Posts
    73

    Default How to: Drop down menu for instant jump to category?

    I want to make a simple drop down menu that will be placed in the header, so users can instanly jump to any category, from any page. Right now, the user has to return to the main page in order to change categories, so I am trying to make the site more user friendly. The categories should stay updated automatically as categories are added or deleted.

    Any ideas?

    Thanks in advance.
    Version 5.4.0
    Paid Single Domain
    Auto Directory
    Airline Forum, Pictures and Videos

  2. #2
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    I never found that folks used the "jump to" list and i never use them myself. but ....

    a couple of things. if you have lots of categories (thousands), then you you may not want to put them on the page - takes time to download them. but browsers cache pages and INDEXU caches pages. so maybe no problem.

    also you may want to re-visit the idea to create them dynamically for EVERY page if you have "lots of them." same reason as in previous paragraph.

    besides, once you get your site up and running, you don't tend to add categories. even if one or two is missing from the list, they are not likely to be missed. unless you have thousands of daily visitors.

    since you don't have any sub-cats, you could just get yours off the index page. with a good text editor (editplus.com) you could create a dropdown list in a matter of a few minutes.

    or write a php program to do it. I don't think i have seen one but i remember discussing something like this before with someone else.



    .
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  3. #3
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,732

  4. #4
    Join Date
    Jul 2006
    Posts
    73

    Default

    Quote Originally Posted by dody
    It will be included in next release, see the codes here: http://nicecoder.com/svn/index.php?act=changeset&id=265

    Good to hear. Although, that link doesn't show me any code. I am sure you get asked this all the time, but what is your time frame for the next release?
    Version 5.4.0
    Paid Single Domain
    Auto Directory
    Airline Forum, Pictures and Videos

  5. #5
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    Quote Originally Posted by enginerunup
    ... what is your time frame for the next release?
    see http://www.nicecoder.com/community/s...ead.php?t=3642

    Quote Originally Posted by dody dated:05-24-2006, 02:06 PM
    Indexu 5.1.1 ... This is a monthly maintenance release aiming for bug fixing and a few enhancements.
    I guess some months have a different number of days depending on which part of this small planet one happens to inhabit.


    .
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  6. #6
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,732

    Default

    I guess some months have a different number of days depending on which part of this small planet one happens to inhabit.
    We skipped the June release, but you will get the July release very soon

  7. #7
    Join Date
    Jul 2006
    Posts
    73

    Default

    Quote Originally Posted by dody
    It will be included in next release, see the codes here: http://nicecoder.com/svn/index.php?act=changeset&id=265

    If the update is coming very soon, then no worries, but if it is going to be a little while, can you post the code and files, the link above doesn't show anything.

    Thanks.
    Version 5.4.0
    Paid Single Domain
    Auto Directory
    Airline Forum, Pictures and Videos

  8. #8
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,732

    Default

    Here is the code

    /blocks/block.category_jump.php
    PHP Code:
    function block_category_jump($params) {
      global 
    $dbConn$site_url$cat$category_separator;

      if (!
    $params['template']) {
        
    $params['template'] = 'block.category_jump.html';
      }

      
    $tpl = new Template;

      
    $query_filter "";
      if (
    $params['type'] == 'main') {
        
    $query_filter "and a.parent_id = '0'";
      }
      if (
    $params['type'] == 'sub') {
        
    $query_filter "and b.parents like '%;$cat;%'";
      }
      if (
    $params['type'] == 'all') {
        
    $query_filter "";
      }

      
    $query "select a.category_id, b.path, b.path_with_url
                from idx_category a
                     left join idx_category_path b on (a.category_id = b.category_id)
                where visible = 1 $query_filter
                order by b.path asc"
    ;
      
    $result $dbConn->Execute($query);

      while (
    $row $result->FetchRow()) {
        
    preg_match_all('|<a href="(.*?)"|msi'$row['path_with_url'], $match);
        
    $row['path_with_url'] = $site_url '/' $match[1][@count($match[1]) - 1];
        
    $paths explode($category_separator$row['path']);
        
    $row['path'] = str_repeat('&nbsp; ', (@count($paths) - 1) * 3).$paths[@count($paths) - 1];
        
    $categories[] = $row;
      }
      
      
    $tpl->assign('cat'$cat);
      
    $tpl->assign('categories'$categories);
      
    $tpl->display('blocks/'.$params['template'], 0);


    /themes/kosmos/blocks/block.category_jump.html
    PHP Code:
    <%if $categories%>
    <
    script language="javascript" type="text/javascript">
    function 
    category_jump(targ,selObj,restore){
      eval(
    targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
      if (
    restoreselObj.selectedIndex=0;
    }
    </script>
    <form action="" name="categoryjump_frm">
    Category Jump :
    <select name="select" onchange="category_jump('parent',this,0)">
      <%section name=i loop=$categories%>
        <option value="<%$categories[i].path_with_url%>" <%if $cat == $categories[i].category_id%>selected="selected"<%/if%>>
          <%$categories[i].path%>
        </option>
      <%/section%>
    </select>
    </form>
    <%/if%> 

  9. #9
    Join Date
    Jul 2006
    Posts
    73

    Default

    Thanks for the code. I made the files, and uploaded them, but nothing has changed. I believe this is because I haven't placed any code in the header.html file to call it up. What should I add to 'activate' these new files?

    Thanks again for your help.
    Version 5.4.0
    Paid Single Domain
    Auto Directory
    Airline Forum, Pictures and Videos

  10. #10
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,732

    Default

    You need to call the block from any template you like

    Code:
        <!-- category jump -->
        <div align="right">
        <%block_category_jump type="all"%>
        </div>

  11. #11
    Join Date
    Jul 2006
    Posts
    73

    Default

    I am trying to put it in my header file, but this is the error that I get:

    function block_category_jump($params) { global $dbConn, $site_url, $cat, $category_separator; if (!$params['template']) { $params['template'] = 'block.category_jump.html'; } $tpl = new Template; $query_filter = ""; if ($params['type'] == 'main') { $query_filter = "and a.parent_id = '0'"; } if ($params['type'] == 'sub') { $query_filter = "and b.parents like '%;$cat;%'"; } if ($params['type'] == 'all') { $query_filter = ""; } $query = "select a.category_id, b.path, b.path_with_url from idx_category a left join idx_category_path b on (a.category_id = b.category_id) where visible = 1 $query_filter order by b.path asc"; $result = $dbConn->Execute($query); while ($row = $result->FetchRow()) { preg_match_all('|assign('cat', $cat); $tpl->assign('categories', $categories); $tpl->display('blocks/'.$params['template'], 0); }
    Warning: Smarty error: [in header.html line 142]: syntax error: custom function 'block_category_jump' is not implemented (Smarty_Compiler.class.php, line 794) in /homepages/3/d97457417/htdocs/erstorecc/directory/lib/smarty/Smarty.class.php on line 1088




    Any ideas? Is there a specific place to put it in the header.html file?
    Version 5.4.0
    Paid Single Domain
    Auto Directory
    Airline Forum, Pictures and Videos

  12. #12
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,732

    Default

    The easiest way is download the latest version and then uplaod the category jump block files:
    /blocks/block.category_jump.php
    /themes/kosmos/blocks/block.category_jump.html

    And put the invocation code, try in browse.html first
    Code:
        <!-- category jump -->
        <div align="right">
        <%block_category_jump type="all"%>
        </div>

  13. #13
    Join Date
    Feb 2004
    Posts
    455

    Default

    Hello,

    I like the idea of a "Jump to an other category" but I would prefer to have it display in a block on the left side of the screen. I have over 1500 categories, I would prefere to limit the my block to top categories (no sub-categories) how could I do that?
    I want something more like I did here:
    http://www.e-gun.com/browse-classifi...ction-2-1.html
    On the left of the screen under "Categories"
    Thanks,
    Last edited by aladdin1; 07-23-2006 at 09:51 AM.

  14. #14
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,732

    Default

    Try this query in block.category_jump.php
    Code:
      $query = "select a.category_id, b.path, b.path_with_url
                from idx_category a
                     left join idx_category_path b on (a.category_id = b.category_id)
                where visible = 1 and a.parent_id=0 $query_filter
                order by b.path asc";

Similar Threads

  1. Category Jump Hack/Mod
    By esm in forum v3.2
    Replies: 5
    Last Post: 01-23-2004, 11:27 AM
  2. Using Radio Button and Drop Down Menu in Custom Field
    By dody in forum Tutorials, Hints & Tips
    Replies: 2
    Last Post: 12-20-2003, 10:58 PM
  3. dynamic drop down menue
    By persut in forum v5.x
    Replies: 1
    Last Post: 11-23-2003, 09:18 PM
  4. dynamic category menu on every site
    By Frank71 in forum v3.2
    Replies: 3
    Last Post: 09-13-2003, 06:20 AM
  5. Category Jump Hack/Mod ??
    By ideavirus in forum v3.2
    Replies: 9
    Last Post: 06-27-2003, 10:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •