Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
asy_category_tags - Some additional category Tags
This was written in response to this discussion:
http://forum.textpattern.com/viewtopic.php?id=2377
1) Article-Form-Tag: Shows Categories, if they are set. (can only be used in an article form)
<:txp:asy_showcat link=“true /> link is optional. If the article has categories set, this will output
a text like (filed under catName). If link is set to true, catName will be a (section-aware) link.
2) Page-Tag: Show all categories of current section that have articles in them.
<:txp:asy_category_list label=“Some free text” wraptag=“p” break=“br” /> All attributes are optional.
3) Page-Tag: Show all categories of current section that have articles in them. (popup)
<:txp:asy_category_popup label=“Some free text” wraptag=“p” break=“br” /> All attributes are optional.
<strike>Version: 0.5 Date: 22.06.04
Version 0.6 Date: 24.06.04
Version 0.65 Date: 26.06.04</strike>
Version 0.7
Date: 27.06.04
Note: Since there is no clearly defined API, these funxtions tap into some global variables ($thisarticle, $pfr, $url_mode) , which theoretically could change in the future. This version was tested with g1.19, and there is a small possibility this may not work as is in future releases.
Download: http://www.sencer.de/code/asy_category_tags.txt
Have Fun.
Last edited by Sencer (2004-06-27 09:31:21)
Offline
Re: asy_category_tags - Some additional category Tags
Fixed a bug in the previous version (hardcoded section-name).
Added 3rd tag: txp:asy_category_popup
Offline
#3 2004-06-25 09:22:26
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: asy_category_tags - Some additional category Tags
Sencer, I can use your asy_showcat tag because with txp:category1 and 2 I found that it shows only the first word of a category that has a three word name (say: nuts & bolts) when link was set to “1”. Your tag shows the complete category name, and only if a category is set, which is great, but now I have another problem: when setting link to true, the output is nuts & a m p ; bolts (without the spaces of course but otherwise it won’t show here). I don’t want to change it back to just & because I want to have valid xhtml.
Is there a way to solve this?
Thanks.
Last edited by doggiez (2004-06-25 09:30:28)
Offline
Re: asy_category_tags - Some additional category Tags
Hi doggiez,
I myself have a category that is named “Tools & SW”, and the pages validate just fine. That’s of course because every place that I output the category-name I convert it. If I am not mistaken, that is how Dean does it with the categories too (at least in g1.19).
Re: Your problem: Would changing the name to “nuts & bolts” and re-checking all the places where you output the category-name be an option?
Offline
#5 2004-06-25 16:20:15
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: asy_category_tags - Some additional category Tags
O.k. I changed it and it still validates. It’s not errors that I get but warnings: “character “&” is the first character of a delimiter but occurred as data”. I can live with that ;-)
Thank you for your answer.
Offline
Re: asy_category_tags - Some additional category Tags
Thank you so mutch for the popup-part, Sencer!
Any chance it could be made to work with messy urls as well?
when I click on a category, the url goes: <code> /rootfolder/s=sectionname?c=categoryname </code>
The questionmark is displayed immediately before the select-name. It seems the select-name has to contain the whole url-bit, or??
(That is also why I couldn’t get it to work if I handcoded the popupmenus.)
I have to use messy urls for the time beeing, in order to make the section-popup work, among other reasons. That’s why it would be great for me, if it’s not too mutch work for you.
Again – thank you.
Last edited by fri (2004-06-26 20:29:28)
Offline
Re: asy_category_tags - Some additional category Tags
Hi fri,
I coded with messz urls in mind, but I made a little ommission.
Anzwaz I hope I fixed the bug now. Updated to version/number 0.65< I can|t test right now. I hope it works now…
Offline
Re: asy_category_tags - Some additional category Tags
Thanks, Sencer, but it doesn’t work…
Are you still on for a version 0.7?
It seems that as soon as the url from the form-tag gets a question mark, it is overridden by the somehow encoded url in the select-name.
Result: only “?c=categoryname” – section gets ‘eaten up’.
I tryed to put it all in the select-name like this:
<code>$out =’<select name=“s=’.$s.a.‘c” onchange=“submit(this.form)”>’.n.t.’<option value=”“></option>’.n;</code>
because that displays the correct ‘grammar’ of:
/?s=section&c=category,
but then I end up with the mumblejumbled “=” and “&” beeing displayed as “%3D” and such.
I’m sorry it has to be such a pain!
You think it can be fixed?
Offline
Re: asy_category_tags - Some additional category Tags
Hi fri,
now I really fixed it (and tested it ;) ).
I am passing the section as a hidden input in the form. Since the form method is GET appending to the URL didn’t work (It works with POST though; that’s why I remembered it wrong).
Have fun. Updated to 0.7
Offline
Re: asy_category_tags - Some additional category Tags
Hurrah for you and for your hidden values!
Thank you so mutch, for this and for taking it up in the first place.
That is what I needed – I will be able to move on now!
Offline
#11 2004-07-30 21:57:24
- spchampion
- Archived Plugin Author
- Registered: 2004-06-10
- Posts: 62
Re: asy_category_tags - Some additional category Tags
Hi! I made a modification to your asy_category_list tag that allows it to take a section directive. I’m using this to output a list of categories that only appear in a certain section (for archiving purposes). Here are my changes:
In the function asy_category_list, add the following line after $break=…
<pre>
<code>
$section = $section ? $section :$s;
</code>
</pre>
Later, after $q = …, change the part that says $pretext[“s”] to $section. Make sure you keep the “.” characters between $section and the quote symbols.
Scrolling down a little further, there’s an if statement like if($rs). Inside this if statement is a line beginning with $out[]. Change the part that says $pfr.$s to $pfr.$section. Once again, respect the placement of the “.” characters.
Finally, do the same thing for the later $out, except this time change the portion that says urlencode($s) to urlencode($section).
All done!
Offline
Re: asy_category_tags - Some additional category Tags
Could someone post some example tags?
I would like to display only the catagories that are in the currently viewed section without subcatagories if possible. Or should I eliminate subcatagories alltogether? I can’t seem to get this to fuction. It only displays the text of the tag where I place it. I also tried it in a form.
Thanks
Jamie
Last edited by soulship (2004-10-02 20:52:59)
Offline