Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#529 2009-01-03 13:53:05
- christopheradams
- Member
- Registered: 2008-12-04
- Posts: 11
Re: tru_tags: A tagging plugin for textpattern
I’m trying to use tru_tags to display search results by section, rather than in one long list.
However, I finally realized that this doesn’t work:
<txp:tru_tags_if_tag_search>
Section A matching <txp:tru_tags_tag_parameter />: <txp:tru_tags_handler section="SectionA">
Section B matching <txp:tru_tags_tag_parameter />: <txp:tru_tags_handler section="SectionB">
</txp:tru_tags_if_tag_search>
Unless the sections BOTH contain the tag being searched for. If one section does not, that call to tru_tags_handler returns a 404 error.
Is there any way to list search results by section? Or to ask tru_tags to just do nothing if it can’t match a tag for that section? I suppose that I could render the section name alongside each article, but I would rather have two separate lists.
It seems the way tru_tags_handler is implemented, I either have to show search results for only one section, or for all of them. Am I missing something?
Offline
#530 2009-01-03 14:27:49
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: tru_tags: A tagging plugin for textpattern
jstubbs wrote:
Here you go:
Jonathan, the code you posted seems to have the same problem as I had a while ago while trying to post the MLP strings, if someone copies that it won’t work. See here how to solve it.
Last edited by els (2009-01-03 14:29:24)
Offline
#531 2009-01-03 15:00:01
Re: tru_tags: A tagging plugin for textpattern
Nothing wrong with it Els – works fine. Just tested. The line endings were already Unix, I use Text Wrangler and that is the default line ending I think.
Offline
#532 2009-01-03 15:17:37
- christopheradams
- Member
- Registered: 2008-12-04
- Posts: 11
Re: tru_tags: A tagging plugin for textpattern
jstubbs wrote:
Nothing wrong with it Els – works fine. Just tested. The line endings were already Unix, I use Text Wrangler and that is the default line ending I think.
I likewise had no problem installing tru_tags 3.3 from the code that jstubbs posted.
Offline
#533 2009-01-03 16:26:36
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: tru_tags: A tagging plugin for textpattern
jstubbs wrote:
Nothing wrong with it Els – works fine. Just tested.
Good to hear that! Apologies for causing confusion then.
Offline
#534 2009-01-04 04:15:03
- christopheradams
- Member
- Registered: 2008-12-04
- Posts: 11
Re: tru_tags: A tagging plugin for textpattern
christopheradams wrote:
I’m trying to use tru_tags to display search results by section, rather than in one long list.
I’ve found my own solution to this problem. Instead of calling tru_tags_handler for each section, I call article_custom for each section and then use the value of tru_tags_tag_parameter as the keyword query. Exempli gratia:
<txp:article_custom section="sectionA" keywords='<txp:tru_tags_tag_parameter />' />
<txp:article_custom section="sectionB" keywords='<txp:tru_tags_tag_parameter />' />
Update: Of course, I just realized my solution fails if the tag has a space in it. For instance, tru_tags_tag_paramter
returns “two-words”, but I assume article_custom
would only return a match for “two words”
Last edited by christopheradams (2009-01-04 04:29:43)
Offline
#535 2009-01-04 17:41:41
Re: tru_tags: A tagging plugin for textpattern
christopheradams – try using '<txp:tru_tags_tag_parameter striphyphens="lookup" />'
– that will spit out the tag parameter exactly as it was originally typed (with or without the dashes)
Offline
#536 2009-01-04 23:51:21
- christopheradams
- Member
- Registered: 2008-12-04
- Posts: 11
Re: tru_tags: A tagging plugin for textpattern
truist wrote:
christopheradams – try using
'<txp:tru_tags_tag_parameter striphyphens="lookup" />'
– that will spit out the tag parameter exactly as it was originally typed (with or without the dashes)
Truist, thanks for your response. tru_tags is a very well thought-out plug-in.
I had noticed the usage of striphyphens for display purposes but had glossed over the “lookup” attribute.
My specific case is that none of my tags (“keywords”) are hyphenated. It would appear that the links generated by tru_tags_cloud
and tru_tags_from_article
always link to mysite.dom/tag/two-words/
and that the value of '<txp:tru_tags_tag_parameter striphyphens="lookup" />'
is therefore also two-words
, which does not match anything in my database.
What did work for me however is '<txp:tru_tags_tag_parameter striphyphens="1" />'
. For example:
<txp:article_custom section="SectionB" keywords='<txp:tru_tags_tag_parameter striphyphens="1" />' limit="1000" />
However, it seems this would break if I had mixed-use cases (i.e., if some of my keywords used hyphens and some used spaces). I vaguely recall a warning about not having mixed spaces and hyphens in the keywords, so I’ve committed to using spaces. Do I have this right?
Again, thanks for your help. Your mention of striphyphens
pointed me in the right direction.
Offline
#537 2009-01-05 05:38:04
- Logoleptic
- Plugin Author
- From: Kansas, USA
- Registered: 2004-02-29
- Posts: 482
Re: tru_tags: A tagging plugin for textpattern
jstubbs wrote:
Here you go:
Thanks for posting the code, Jonathan. I’ve been looking for that.
Offline
#538 2009-01-06 22:46:00
Re: tru_tags: A tagging plugin for textpattern
christopheradams wrote:
My specific case is that none of my tags (“keywords”) are hyphenated. It would appear that the links generated by
tru_tags_cloud
andtru_tags_from_article
always link tomysite.dom/tag/two-words/
and that the value of'<txp:tru_tags_tag_parameter striphyphens="lookup" />'
is therefore alsotwo-words
, which does not match anything in my database.
Hm, “lookup” should have done the right thing. Are you using v3.3? Maybe there’s a bug.
However, it seems this would break if I had mixed-use cases (i.e., if some of my keywords used hyphens and some used spaces). I vaguely recall a warning about not having mixed spaces and hyphens in the keywords, so I’ve committed to using spaces. Do I have this right?
You have this almost right. There is a warning about mixing spaces and hyphens in a single tag. For example, a “tag like-this” is bad. But you should be fine to have some tags with hyphens and some with spaces – so long as “lookup” works. If “lookup” doesn’t work, then your best best is to standardize on one type or the other.
Offline
#539 2009-01-07 03:54:25
- christopheradams
- Member
- Registered: 2008-12-04
- Posts: 11
Re: tru_tags: A tagging plugin for textpattern
truist wrote:
Hm, “lookup” should have done the right thing. Are you using v3.3? Maybe there’s a bug.
Yes, I am using v3.3 ; I didn’t start really using tru_tags until this version.
One thing to keep in mind is that I’m not doing a tag search based on a query that the user enters into a textfield. I’m doing a search based off of the links generated by the tag_cloud.
So, let’s say my keyword is “two words”
The tag cloud will then generate the text “two words” which is a link to http://mysite.dom/tag/two-words/
If I click on that link, the value of <txp:tru_tags_tag_parameter striphyphens="1" />
is two words
which finds a match.
In the same case, the value of <txp:tru_tags_tag_parameter striphyphens="lookup" />
is two-words
, which will not find a match.
However, I found that if I manually type in http://mysite.dom/tag/two words
(yes, with a space!) then striphyphens=“lookup” does find a match.
So striphyphens=“lookup” seems to be looking up the literal value of the URL (or wherever it derives the string from), and not the “real” value of the tag.
Is this not as it should be?
Offline
#540 2009-01-23 02:03:52
Re: tru_tags: A tagging plugin for textpattern
Hi Nathan,
Lovely plugin (even tho next para is a support Q, I really do mean that ;)
I just posted a Q to your /trutags-usage-instructions page at rainskit.com, please let me know if that was the wrong place.
Cheers, -Alan
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline