Categories:
Author:
About It:
Rate it:
Flag it:
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
-
- 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>
Posted here:
05 Apr 2005Article modified:
06 Nov 2006









Comments/questions? Leave a message in the form.
Commented (9)
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.
admin > presentation > pages, on the left-hand side “popup”.
There are also a similar plugins:
* zem_popup_cat
* asy_category
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.
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
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?