Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-02-12 00:10:18

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

A better txp:popup tag

Today I’ve caught up with all the excellent refinements in txp’s category_list tag like parent and exclude attributes :-)

I would like to see similar enhancements for the txp:popup tag.
I’m aware that these drop-down menus aren’t very pretty due to poor support for css styling in the browsers, but it’s still an excellent way to offer a powerful means for navigation.

In particular I’d love to see support for the little-used optiongroup tag, used to neatly devide the list of possible selections. Let’s say you have a number of categories all assigned to one parent category. At the moment the popup tag gives you a flat listing of all categories with the parent ones as selectable items, too, which might not be what you want. I’d rather see the parent wrapped with an optiongroup tag, so it can’t be selected.

You can see an example right here in the txp forum if you click in the Jump to menu at the top left. The items Textpattern, Support, Community and International Users are only used as dividers but not selectable. Sadly only IE5 Mac supports the tag to its full extent

Anyone else?

Cheers Martin

Last edited by masa (2007-12-17 13:20:40)

Offline

#2 2007-12-16 03:11:22

mattmikulla
Member
From: Nashville Tennessee
Registered: 2004-08-25
Posts: 281
Website

Re: A better txp:popup tag

Yea. I’d like a way to exclude a parent category.


Art Rogue – Fine Art Photography

Offline

#3 2007-12-16 05:40:10

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: A better txp:popup tag

Well, that makes at least two of us :-)

Thinking about it again, I wonder whether it’s possible to produce such a popup with a custom form employing any of the available category plugins?!

Any hints would be very much appreciated!

Cheers Martin

Offline

#4 2007-12-16 06:55:21

iblastoff
Plugin Author
From: Toronto
Registered: 2006-06-11
Posts: 1,197
Website

Re: A better txp:popup tag

this looks like a good learning opportunity for me and something i can actually handle. i’ll attempt to write a plugin for this (basically put parent categories as optgroups and then list its children underneath them as choices).

i’ll get back to this thread when i (hopefully) have something.

Last edited by iblastoff (2007-12-16 10:21:26)

Offline

#5 2007-12-16 07:15:16

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: A better txp:popup tag

Great!

If you want to put your plugin up for ransom, please, let us know – I’d be happy to contribute.

Offline

#6 2007-12-16 09:33:55

iblastoff
Plugin Author
From: Toronto
Registered: 2006-06-11
Posts: 1,197
Website

Re: A better txp:popup tag

hey masa, let me know if this is the type of thing you’re looking for:

check the category popup on the right

so far the plugin isn’t as optimized as i’d like but its basically a modification of the normal <txp:popup /> tag (in this case its <txp:lam_popup />

currently, its taking the category name rather than the category title as the <optgroup> but shouldn’t be much longer to get that sorted.

also, it leaves out any empty parent categories (i’m assuming this would be the wanted action seeing as optgroups are not selectable. so there’d be no point in listing it if it contains no children categories)

accepts all attributes as <txp:popup /> (except “type” since you obviously can’t do this with sections yet)

edit: alright i got it to read the category name instead of the title, but now the caveat is the popup will include any empty parent categories if you have them. gah!

Last edited by iblastoff (2007-12-16 14:52:20)

Offline

#7 2007-12-16 18:12:40

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: A better txp:popup tag

Wow, Steve, that was quick!

Yes, that’s exactly what I had imagined. Displaying the category titles would indeed be preferable since I usually need to fumble around with the names to get them to display in the order I need.

I wouldn’t be bothered by empty parent categories appearing since that can be easily avoided.

I was wondering however, whether it could be modified to display only certain categories by listing the parent names as attribute values like so this tag <txp:lam_popup category="fish, vegetable" />

…would render:

Fish
  • Cod
  • Haddock
  • Monkfish
Vegetables
  • Cauliflower
  • Potatos
  • Tomatos

?

Thanks for taking the time!

Offline

#8 2007-12-16 18:40:54

mattmikulla
Member
From: Nashville Tennessee
Registered: 2004-08-25
Posts: 281
Website

Re: A better txp:popup tag

Thanks Steve. That’s just what I’m looking for. I like masa’s idea as well. That would make the plugin really functional.


Art Rogue – Fine Art Photography

Offline

#9 2007-12-16 21:54:12

iblastoff
Plugin Author
From: Toronto
Registered: 2006-06-11
Posts: 1,197
Website

Re: A better txp:popup tag

I think i may have it now.

view this page again for the demo

the tag i’m using is <txp:lam_popup label="lam_popup demo" categories="another-parent, city" wraptag="p" />

if you do not specify any categories then it will return ALL parent categories regardless of whether they have children or not. also now outputs the category title correctly instead of the name (the one with dashes).

i’m not particularly proud about the amount of sql queries i’m using to do this (i’m far from a php guru) but it seems to be working. now i just have to refactor a bit and write the help blahblahblah and voila. should have something here by the end of the day.

right now it shoots everything out in alphabetical order (parents displayed alphabetically and then each child under each parent alphabetically). i’ll see if i can add some form of sort attribute.

Last edited by iblastoff (2007-12-16 23:36:54)

Offline

#10 2007-12-17 03:29:00

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: A better txp:popup tag

Steve, that looks brilliant!

I’m looking forward to the final version.

Best Martin

Offline

#11 2007-12-17 04:37:13

mattmikulla
Member
From: Nashville Tennessee
Registered: 2004-08-25
Posts: 281
Website

Re: A better txp:popup tag

Agreed, Brilliant. Perfect for my next project.


Art Rogue – Fine Art Photography

Offline

#12 2007-12-18 06:49:21

iblastoff
Plugin Author
From: Toronto
Registered: 2006-06-11
Posts: 1,197
Website

Re: A better txp:popup tag

masa wrote:

Great!

If you want to put your plugin up for ransom, please, let us know – I’d be happy to contribute.

v0.1 is available here

please leave feedback/bugs in that thread (not here).

i also thought about any form of low ransom but the quality of the coding is probably not worth paying for. that being said, i’d be happy to accept any donations as i have a paypal donate button at the bottom here :)

Offline

Board footer

Powered by FluxBB