Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-03-10 20:30:59

element
Member
Registered: 2009-11-18
Posts: 99

Pulldown category menu for search

How do I make a pulldown menu with categories and make it go to a search page/section?

I know <txp:popup> exists but I can’t let it go to the search section and it’s missing a search button because it jumps straight to a page without button.

Offline

#2 2010-03-10 23:44:21

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 453
Website

Re: Pulldown category menu for search

Will the code in this thread solve your your problem, element?

I created it to go to different sections, but it should be possible to have it go to different categories instead.

UPDATE: In response to your question, I have tested and updated the code in the thread linked above. It now does exactly what you want, and some!

Last edited by Kjeld (2010-03-11 02:43:49)


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#3 2010-03-11 12:24:33

element
Member
Registered: 2009-11-18
Posts: 99

Re: Pulldown category menu for search

I should have been a bit clearer.

I don’t want to search in a specific category. I just want to see all the articles in that category when I select a category in the pulldown and with a search button, I don’t want the ‘onchange’ crap.
Also, the options (categories) generated must be automatically because I don’t know the categories beforehand and they can change.

What I need is <txp:popup> on steroids. <txp:popup> won’t let you add a search button and won’t let you specify the section to go to (a search page).

Found a solution (thanks to your code)!

<form method="get" action="<txp:site_url/>search">
<select name="q">
<option value="" selected="selected">&nbsp;</option>
<txp:category_list break="" type="article">
<option value="<txp:category title="1"/>"><txp:category title="1"/></option>
</txp:category_list>
</select>
<input type="submit" value="Search"/>
</form>

Last edited by element (2010-03-11 12:56:50)

Offline

#4 2010-03-12 01:56:59

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 453
Website

Re: Pulldown category menu for search

Great, element! Glad I could help.


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#5 2010-03-12 18:34:16

element
Member
Registered: 2009-11-18
Posts: 99

Re: Pulldown category menu for search

An additional question, is it possible to only show categories which has an article in that pulldown menu or maybe even better add a number next to the category with the amount of articles in that category.

Last edited by element (2010-03-12 18:34:59)

Offline

#6 2010-03-12 20:33:26

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Pulldown category menu for search

element wrote:

…only show categories which has an article

Use the variable and if_variable tags, like in this tip on TXP Tips.

add a number next to the category with the amount of articles in that category.

You can use a plugin (rah_function) to do that.

Offline

Board footer

Powered by FluxBB