Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2015-10-10 16:27:24

vlad
New Member
Registered: 2015-10-03
Posts: 7

How do I use select -> option?

Hi, I’m really confused on how to go about making a category list in a dropdown.

<txp:category_list wraptag="select" break="option" />

That is my code but when I click on an item, it doesnt load. How do I make them link to their respective destinations?

Also, is there any way to make the very first option DISABLED and say ‘Categories’?

Thanks in advance.

Offline

#2 2015-10-10 17:59:43

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,925
Website GitHub

Re: How do I use select -> option?

Hmm, because option needs a number of attributes, you can’t do it quite as succinctly. Try something like this:

<select name="select">
  <txp:category_list break="">
    <option value="<txp:category url="1" />"><txp:category title="1" /></option> 
  </txp:category_list>
</select>

You might need to adapt the link in the value attribute to however your site is structured and if you are within a section (for example to <txp:site_url /><txp:section />?c=<txp:category />) .


TXP Builders – finely-crafted code, design and txp

Offline

#3 2015-10-10 19:22:19

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: How do I use select -> option?

Just for completeness’sake (cause jakob’s solution is certainly more flexible):

txp:popup doesn’t really pop up. (Did it ever?)

<txp:popup label="Browse categories" type="c" />

No disabled first item saying “Categories”, sorry, just a label field. You’d need rah_replace to change the HTML.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#4 2015-10-10 22:15:12

vlad
New Member
Registered: 2015-10-03
Posts: 7

Re: How do I use select -> option?

Hi Jacob, thanks for the reply. I tried that code but when I click on the items, nothing happens. You mentioned that I need to change the link/value to adapt but I’m not sure what you mean exactly. How do I tell how my site is structured?

Thanks.

Offline

#5 2015-10-10 22:20:25

vlad
New Member
Registered: 2015-10-03
Posts: 7

Re: How do I use select -> option?

uli wrote #295580:

Just for completeness’sake (cause jakob’s solution is certainly more flexible):

txp:popup doesn’t really pop up. (Did it ever?)

<txp:popup label="Browse categories" type="c" />

No disabled first item saying “Categories”, sorry, just a label field. You’d need rah_replace to change the HTML.

Hi, I apologize but I am not quite at the level you are on with Textpattern. If you don’t mind, could you rephrase in simpler terms.

Thank you.

Offline

#6 2015-10-10 22:39:10

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,925
Website GitHub

Re: How do I use select -> option?

I tried that code but when I click on the items, nothing happens

Well, you obviously have to either wrap it into an HTML form tag and add a submit button or if you want it to reload a page when you make a selection, you need some javascript (example). The select dropdown is just a chooser. It doesn’t do anything except select an option.

For this use case, it would be better to use a normal ul-list with standard links and style it with css like a drop-down (example)

could you rephrase in simpler terms

txp:popup creates a ready-made category selector. Try it out. It has its own standard wording. Uli suggested that if you want another wording you can use another plugin called rah_replace to change it to use your own wording.


TXP Builders – finely-crafted code, design and txp

Offline

#7 2015-10-11 22:27:43

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: How do I use select -> option?

OK, that’s not been my day, it seems, been talking in riddles here several times. Thanks, Julian, for the translation (and the link).


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

Board footer

Powered by FluxBB