Content last modified Monday 6 March 2017
hop to #bottom
Categories:
Author:
Mary
About It:
Rate it:
  • Helpful?
  • 0 Yes
  • 0 No
Flag it:
Contact Reason [ ? ]

Section and Category Pull-down Menus

Creating a pull-down menu (also known as a “jump” or “select” or popup menu) of articles is very simple. What follows uses JavaScript to power it, but can be changed to use another programming language if desired.

In “jump-menu”, an article form:
<option value="<txp:permlink />"><txp:title /></option>

Page examples (for any version)

Examples to use within a “page”.

Replace

  • section-name with the name of your section
  • category-name with the name of your category
    1. with how many options to generate (to get 5 options, enter 5). If you do not specify a limit, the default number, 10, will be used.

Drop-down by section <form action=""> <select onchange="document.location=options[selectedIndex].value;"> <option value="" selected="selected">Articles In section-name</option> <txp:article_custom section="section-name" form="jump-menu" limit="#"" /> </select> </form>

Drop-down by category <form action=""> <select onchange="document.location=options[selectedIndex].value;"> <option value="" selected="selected">Articles in category-name</option> <txp:article_custom category="category-name" form="jump-menu" limit="#" /> </select> </form>

Pull-down for Section and Category

You can also mix section and category, which would return articles from section-name that also are in category-name.

<form action=""> <select onchange="document.location=options[selectedIndex].value;"> <option value="" selected="selected">Articles in section-name and category-name</option> <txp:article_custom section="section-name" category="category-name" form="jump-menu" limit="#" /> </select> </form>

Article Request Count:
Posted here:
05 Apr 2005
Article modified:
06 Nov 2006

Comments/questions? Leave a message in the form.

Your comment will NOT be submitted until you click the 'Submit' button on the next pageload.

Commented (9)

Aaron Boswell:
Hi mary.

Thanks for the article and helping me out before. Is there any way in this setup to get a list of categories instead of articles within the category? I want to keep the functionality above but still just show a pulldown list of categories.
Aaron Boswell:
Never mind. I hacked the taghandlers.php file to do what I wanted. Thanks, anyway.
Mary:
A built-in tag for this exists.
admin > presentation > pages, on the left-hand side “popup”.

There are also a similar plugins:
* zem_popup_cat
* asy_category
Aaron Boswell:
Thanks,

I checked those out and they work as advertised.

But I wanted there to be ititial text in the pull down and thought just getting into the code would be the best thing.
***so*** useful. thank you!

I’m having trouble to post the code samples here.
To have simple category selects, provided, you have one article per category assigned, this is possible as well, using the same method, as Mary has provided.

I’ll post the link here and open another tip article to get the code snippets displayed properly.

regards, marios

The code samples are posted over here

regards

Just FYI, zem_popup_cat and
asy_category will not work on v. 4.0.4.
( was already mentioned by Sencer in the plugin help)

regards

birdie:

This method doesn’t work in IE7, the script is blocked for security. Can anyone suggest another way?

Subscribe to this article's comments RSS feed. [ ? ]   View Recent Comments across the site.

Would you care to write a comment?

You know you want to visit the Archives.

Browse

Categories


Articles

There are also tag clouds, 'cause those are fun.
Published with Textpattern