Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-12-18 06:45:39

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

lam_category_popup v0.5 (category popup selector using optiongroups)

lam_category_popup v0.5 download here

idea derived from this thread

basically the same thing as <txp:popup /> except it wraps each parent article category in an unselectable <optgroup> tag and lists each child category underneath them for better organization.

kinda hard to explain in words so you can see an example of this plugin at work here (the popup selector on the right)

Changelog:

v0.5 – saved a query for each parent category called
v0.4 – cleaned up some undefined variables (thanks mattmikulla)
v0.3 – using getTree function instead of my own blubbery (thanks bloke)
v0.2 – woops forgot custom prefixes for tables
v0.1 – initial release

Tag:

<txp:lam_category_popup />

Attributes:

Uses all the same attributes as <txp:popup /> (except “type” since theres no parent/child relationship for sections yet)

categories=“categories separated by commas”
  • Choose parent categories to include in popup list.
  • If left blank, ALL parent categories (including empty ones) will show up!
label=“label text”
  • Label for the top of the list.
wraptag=“wraptag text”
  • Character to be used as the wraptag.
  • Default is div
section=“section_name”
  • Jump to the selected category for the named section.
  • Default is empty.
this_section=int
  • Jump to the selected category for the currently active section. Available values: 1 (yes) or 0 (no).
  • Default is 0.
parentsort=“asc or desc”
  • Sorts parent categories.
  • Default is asc
childsort=“asc or desc”
  • Sorts child categories.
  • Default is asc

Example Tag:

<txp:lam_category_popup label="browse" categories="fish, vegetables" parentsort="desc" /> would produce a popup list akin to the following:

browse

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

Credits

Thanks to masa and mattmikulla for the idea. I currently don’t have a use for this plugin myself but I figured I’d give back to the community.

Last edited by iblastoff (2007-12-26 18:33:23)

Offline

#2 2007-12-18 07:57:44

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

Re: lam_category_popup v0.5 (category popup selector using optiongroups)

Hey steve. It’s not working for me. I’ve tried several variations. Heres what I have now. All I see is just the parent category.

<txp:lam_category_popup this_section="1" label="browse" />

also tried

<txp:lam_category_popup categories="color" label="browse" />

txp:popup that is currently working

<txp:popup type="c" this_section="1" label="" />

Last edited by mattmikulla (2007-12-18 07:58:30)


Art Rogue – Fine Art Photography

Offline

#3 2007-12-18 08:19:50

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

Re: lam_category_popup v0.5 (category popup selector using optiongroups)

is “color” a parent category (ie not a child of anything) with child categories assigned to it? or is it a child of something with more children underneath it (which currently won’t work)?

this is the tag i’m using on the demo site : <txp:lam_category_popup label="lam_category_popup demo" categories="city, the-usual, another-parent" wraptag="p" this_section="1" />

this is a screenshot of how my categories are set up:

and once again here is what it outputs:

note that “Empty Parent” category does not show up since i didn’t specify it in my tag.

and it seems to work..i can’t see anything in the code that would be restrictive or specific in any way…hmm…give me a moment i’ll see whats up. by the way are you using any custom prefixes on your db tables?

Last edited by iblastoff (2007-12-18 08:36:39)

Offline

#4 2007-12-18 08:47:47

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

Re: lam_category_popup v0.5 (category popup selector using optiongroups)

the only thing i can think of atm is that i forgot to make sure any custom prefixes you may have for your database were read correctly…

try v0.2 and see if it makes a difference

Offline

#5 2007-12-18 12:34:42

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: lam_category_popup v0.5 (category popup selector using optiongroups)

I think functionality of this plugin should rich the functionality of existing <txp:popup type=“c” />


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

#6 2007-12-18 16:31:39

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

Re: lam_category_popup v0.5 (category popup selector using optiongroups)

Still not working. Color is a parent category. It used to be Moulding Color, but I though that might have been the problem being two words. So under color I have black, white, silver, gold,…

The plugin:

<txp:lam_category_popup categories="color" />

Here’s the html output:

<form method="get" action="http://dev_aspenmoulding_txp:8888/"><div>
Browse<br />
<select name="c" onchange="submit(this.form);">
	<option value="" selected="selected">&nbsp;</option>
	<optgroup label="Color">
	</optgroup>
</select>
<noscript><div><input type="submit" value="Go" /></div></noscript>
</div>
</form>

Art Rogue – Fine Art Photography

Offline

#7 2007-12-18 17:10:18

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,468
Website GitHub

Re: lam_category_popup v0.5 (category popup selector using optiongroups)

Hey iblastoff, just a question about this cool thing: is the onchange always there? I guess it is because it’s a drop-in replacement for the txp popup tag and I think that works the same way iirc.

I only ask because it’s sometimes regarded a bad thing for accessibility. In Firefox it’s not much of a hassle because using keyboard nav into the box and arrowing around doesn’t trigger the page change until Enter is pressed, but on our beloved *cough* IE (6 certainly, not sure about 7) you have to tab into the box then use alt-arrow to pop the list up or else it’ll trigger the page change when you arrow around.

I can see both sides of the argument for using onchange/onblur and against, e.g. I prefer it most of the time but when on my laptop trackpad it annoys me! Is it a hassle to look into adding – even as a plugin option – a ‘Go’ button or similar (MLP-aware if you can)? Or any better ideas if you have them.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#8 2007-12-18 19:30:12

maverick
Member
From: Southeastern Michigan, USA
Registered: 2005-01-14
Posts: 976
Website

Re: lam_category_popup v0.5 (category popup selector using optiongroups)

Matt

What happens if you change categories=”“ from “color” to the original category name “Moulding-Color” (w/ or without capitals, as it was originally created)?

Mike

Offline

#9 2007-12-18 19:43:57

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

Re: lam_category_popup v0.5 (category popup selector using optiongroups)

hmm does this work for anyone else? i have no idea why it wouldn’t be working for you then. it works fine on my local install and on my host. having two words in the category name should be fine as long as you’re using the category name (ie the one with dashes in the name. pretty sure this is default for all category-type plugins). so if you have “Moulding Color” then by default the category name should be “Moulding-Color” unless you manually changed it.

what exactly is the category title AND name of your parent color category? i have a feeling they may be mixed up (at least for how i implemented the checking). whatever the category TITLE is, should be exactly the same as the category name minus any dashes. i may have to revisit this area but for now lets see if thats the problem.

so basically, your category TITLE should be “Moulding Color” while your category name should be “Moulding-Color”.

bloke: yah all i did was play around with the original <txp:popup />. to be honest i definitely don’t use this type of thing at all and just wanted to see if i could write this plugin as a request. quite sure having the option of a submit button wouldn’t be hard though! (even though i’m still new to php). first i just want to make sure it actually works for other people :)

Last edited by iblastoff (2007-12-18 20:09:04)

Offline

#10 2007-12-18 20:20:11

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

Re: lam_category_popup v0.5 (category popup selector using optiongroups)

I tried it on another installation of textpattern. I also tried it on a live site not on my local machine’s server and still no go. I tried different browsers and even restarted my server.

It is outputting the optgroups but not the options. The optgroups are the parent categories as was color and moulding-color before.

<form method="get" action="http://dev_artrogue_v2_txp:8888/"><div>
browse<br />
<select name="c" onchange="submit(this.form);">
	<option value="" selected="selected">&nbsp;</option>
	<optgroup label="About Pages">
	</optgroup>
	<optgroup label="Art Menu">
	</optgroup>
	<optgroup label="Blog Menu">
	</optgroup>
	<optgroup label="Montage Menu">
	</optgroup>
	<optgroup label="Photo Illustration Menu">
	</optgroup>
	<optgroup label="Photography Menu">
	</optgroup>
	<optgroup label="Studio Pictures">
	</optgroup>
</select>
<noscript><div><input type="submit" value="Go" /></div></noscript>
</div>
</form>

Last edited by mattmikulla (2007-12-18 20:21:41)


Art Rogue – Fine Art Photography

Offline

#11 2007-12-18 20:20:38

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

Re: lam_category_popup v0.5 (category popup selector using optiongroups)

Not working here either (txp 4.0.4).

All I see (like Matt) are the parent categories.

Offline

#12 2007-12-18 20:28:40

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

Re: lam_category_popup v0.5 (category popup selector using optiongroups)

interesting. i wonder what the difference between my setup and your setups are. i’ll have to revisit the whole thing i guess. bah

Offline

Board footer

Powered by FluxBB