Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#271 2014-08-05 06:01:24
- saccade
- Plugin Author

- From: Neubeuern, Germany
- Registered: 2004-11-05
- Posts: 521
Re: smd_tags: unlimited article, image, file and link taxonomy
Hi,
on a 4.5.5 install when managing tags the linked cat list is behaving weird:
Sometimes it lists correctly when there is a cat linked to the tag, but sometimes it doesn’t.
It obviously sometimes correctly fetches the linked cat when pressing the “Aktualisieren”-button,
but sometimes deletes the linked cat in the same way.
Also linked cat doesn’t appear regularly when creating a new tag.
So it’s a real cat ;)
Did I miss something here about linked cats?
Offline
#272 2014-08-09 17:28:40
Re: smd_tags: unlimited article, image, file and link taxonomy
saccade wrote #282648:
Did I miss something here about linked cats?
Unlikely! It could be a botched implementation. Do your cats have non-ascii characters in them perchance? Umlauts maybe? Might just be that at a stab in the dark.
If you can give me some examples of your setup (cat hierarchy, names, labels, etc, and a few tag names you’re trying to associate with the cats in question) I’ll try and replicate it when I can and see if I can isolate the cause.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#273 2014-08-09 17:54:09
- saccade
- Plugin Author

- From: Neubeuern, Germany
- Registered: 2004-11-05
- Posts: 521
Re: smd_tags: unlimited article, image, file and link taxonomy
The cat in question (only one so far for the tags, but there are more) is: schwerpunktdekanat-2014-freising
no umlauts and everything strictly ascii
- allershausen
- au
- dorfen-taufkirchen
- eching
- erding
- freising
- markt-schwaben
- moosburg
- neufahrn
- poing
no umlauts as well and even strictly ascii.
There are some single situations when I get the linked cat as a field, but even it doesn’t appear when I use the “manage tags” tab for the first time after logging in. Mostly I think the field appears when I hit create with noting in the fields before.
But even when I activate one of the already existent and (manually!9 linked tags the field doesn’t appear – and the link will be deleted when I save any change.
Just double checked everything: There is one category with an umlaut, not used here, but I’ll delete it now to see if things change. Edit checked that, but no influence. “linked cat” still missing.
To be exact: The label “linked cat” is present, but theres no selection nor any field in it.
Last edited by saccade (2014-08-09 17:56:03)
Offline
#274 2014-08-11 07:49:57
- jpdupont
- Member
- Registered: 2004-10-01
- Posts: 752
Re: smd_tags: unlimited article, image, file and link taxonomy
I’m building a new version of a site with smd_tags. I want to import the category structure of the old site in smd_tags.
I have imported the category table of the old site in the new site.
It seems impossible to import categories in smd_tags if no articles are linked to categories … Right ?
Offline
#275 2014-08-22 10:12:20
Re: smd_tags: unlimited article, image, file and link taxonomy
Hi
I marched through all 28 pages but could not find a simple solution! Maybe overlooked it though…
I have an alphabetic tag list in a right sidebar. More or less the same code as from your example 3 from the tag info page, but without the weighted font-size class. The resulting linear vertical list shows the letters of the alphabet followed by the tag names.
When clicking a tag name the articles with that tag are shown in the main part of the page. What is the easiest way to highlight the clicked tag in the list when the articles with that tag are shown?
thanks
Kees
Offline
#276 2014-09-02 01:41:10
Re: smd_tags: unlimited article, image, file and link taxonomy
Bloke – is it possible to tag users/authors with smd_tags?
Thanks,
Mike
Offline
#277 2014-10-03 14:22:17
Re: smd_tags: unlimited article, image, file and link taxonomy
I have an smd_tags setup as a filter for just one section (called “projects”) and am using the word “filter” as a trigger in the url, so I have urls like this (just examples):
/projects/filter/kent, or/projects/filter/kent+thatch, or/projects/filter/yorkshire|kent|tile…
I use smd_tag_list to show the currently active filter(s) at the top of the filtered project list. That all works great thanks to your brilliant plugin (every version gets a bit better)!
I then set about looking for a way to remove individual filters from the selection and found a perhaps somewhat roundabout method by computing what the url would be for a given page without the tag and using that as the href of the “remove this tag from filter“ button, e.g. the “×”-button for the “Kent” tag in the third example above has the href /projects/filter/yorkshire|tile but in the second example it would be /projects/filter/thatch.
When there is only a single filter active (like in the first example), the computer url is then /projects/filter/. Intuitively (from a user-perspective), I’d expect this to be the same as /projects/ without any filter. Interestingly, however, on the /projects/filter/ page, smd_tag_list outputs ALL the available tags as active filters in a long list (I guess no filter is the same as all filters with the OR operator?).
I thought I could get around this by using smd_redirect to redirect ^/projects/filter/$ to /projects/ but it doesn’t take effect. Why? Is smd_tags getting in there first?
Any suggestions? I guess I could add a step to my url computation code, that checks for an empty filter and corrects the url accordingly to remove the filter/ part too. Or alternatively prevent smd_tag_list from being output when if_tag_list returns true (i.e. trigger is in url) but the tag_list is actually empty. Or do you have a better suggestion for dropping a tag from the current filter?
TXP Builders – finely-crafted code, design and txp
Offline
#278 2014-10-03 15:38:12
Re: smd_tags: unlimited article, image, file and link taxonomy
jakob wrote #284491:
a perhaps somewhat roundabout method by computing what the url would be for a given page without the tag and using that as the href of the “remove this tag from filter“ button
Yes, this is something I’ve been meaning to address. A neat way of being able to add / remove a tag would be very helpful. I’ve tried AJAXy type things, manipulating the URL from Javascript, but the results have so far been unsatisfactory. I have toyed with the idea of special type of URL trigger for ‘add’ and ‘remove’ steps (maybe a minus sign to remove the tag and a caret to add, or something?), but haven’t had that Eureka moment yet. If you do hit upon a cool method (maybe an smd_macro?) that you think might be able to be pluginised, please let me know and I’ll build it in.
But to address your specific problem, yes the absence of any filter shows all available tags. The <txp:smd_tag_list> does just that: lists tags. My reasoning was that, without any input, it has to show you them all so you can start to filter by something, otherwise you’d see nothing and be scratching your head.
As you found, you can circumvent this to a degree by using the conditional <txp:smd_if_tag_list>. If you wrap your <txp:smd_tag_list> in that, it won’t trigger the content unless at least one filter is present in the URL. That could probably be made clearer in the docs, sorry. But it does mean you get no output at all to click. Any way you could detect this by setting a variable and then do a page refresh back to the base URL if the tag returned nothing?
Failing that, if you don’t mind me taking a peek, drop me some credentials and I’ll see if we can figure something out between us to satisfy your requirements.
I thought I could get around this by using smd_redirect to redirect
^/projects/filter/$to/projects/but it doesn’t take effect. Why? Is smd_tags getting in there first?
Precisely that, yes. I think smd_tags is pretty hungry and runs on pretext, which probably pips smd_redirect to the post. You could try lowering the load order of smd_redirect but I don’t think it’ll help much.
Hope that helps. Let me know if I can help at all with the filtering side of things, as it’s part of the plugin I really need to beef up so you don’t have to do so much manual skulduggery.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#279 2014-10-03 20:35:09
Re: smd_tags: unlimited article, image, file and link taxonomy
Thanks for the lightning response. For the moment, I’ve opted to simply make the delete link return to the section landing page if no filter remains. To me that seems most intuitive for the user. My ‘manual skullduggery’ (apt description) requires two mini snippets of txp and looks like this…
Somewhere at top of page template, this snippet:
<txp:php>
global $variable;
// get pieces of: /section/trigger-word/tag-name-or-combination
$pieces = explode ( "/", $_SERVER[REDIRECT_URL] );
// and store in txp variables for later use
$variable['current_url_stub'] = "/" . $pieces[1] . "/" . $pieces[2] . "/";
$variable['current_filter'] = $pieces[3];
</txp:php>
… and then later in the page template where the tag list shows this code (in a slightly less verbose form):
<txp:smd_if_tag_list>
Filtered by:
<txp:smd_tag_list wraptag="ul" break="li" class="tag-list">
<a href="<txp:php>
global $variable, $smd_thistag, $pretext;
// subtract current tag name from the browser filter string stored previously
$remainder =
str_replace( $smd_thistag['tag_name'], '', $variable['current_filter'] );
// clean up remainder string: correct any mid-string instances of || or ++
// and trim any stray | or + sign from beginning and end of string
$remaining_filter =
trim( preg_replace( "/([\|\+])+/", "$1", $remainder ), "|+" );
// if resulting tag filter is empty then return to section page
// otherwise re-assemble complete link using url_stub stored previously
echo ( $remaining_filter == '' ) ?
'/' . $pretext['s'] . '/' : $variable['current_url_stub'] . $remaining_filter;
</txp:php>" title="remove this filter">×</a>
<a href="/<txp:section />/filter/<txp:smd_tag_name title="0" />">
<txp:smd_tag_name title="1" />
</a>
</txp:smd_tag_list>
</txp:smd_if_tag_list>
It works well enough. I’ve just not trapped someone entering /projects/filter/ manually, but that’s no big deal.
The presence of the trigger-word “filter” in the url seems to be enough for txp:smd_if_tag_list to be true even if there are no tags, so the other method would involve outputting the tags into a variable and then testing if that is empty.
TXP Builders – finely-crafted code, design and txp
Offline
#280 2014-10-03 23:04:19
Re: smd_tags: unlimited article, image, file and link taxonomy
jakob wrote #284499:
My ‘manual skullduggery’ requires two mini snippets of txp
Very clever. I’ve been tinkering with those ideas this evening, but not yet found a way to ‘monetize’ them into something generic for the plugin. The major stumbling block seems to be that once you’ve clicked one to add it to the filter, you no longer see the rest of the list from which to choose from because the act of adding it to the URL filters the smd_tag_list to only include the given tag.
My logical brain says there ought to be a way to “break out” of the URL-generated list in order to display a complete list at any time, unencumbered by the in-force tags. Then you could show a list of possible tags and use the add/remove technique to alter the URL and ‘do stuff’. I thought that was already possible, so perhaps there is a way and I’ve just been away from the plugin for too long to remember how to do it. Clearly you’ve managed to solve it in some way, so if you could see your way clear to reveal how you did that bit, I’ll be able to create something akin to your setup on my local dev installation and start to tinker with native mechanisms for adding/removing tags.
Does it rely on some specially crafted URL trigger? Presumably you’re solely triggering on filter? Or some cunning use of tag attributes / smd_related_tags?.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#281 2014-10-04 11:06:25
Re: smd_tags: unlimited article, image, file and link taxonomy
My logical brain says there ought to be a way to “break out” of the URL-generated list in order to display a complete list at any time, unencumbered by the in-force tags.
Yes, a kind of tag_list_custom and a tag_list. I’ve not (yet) dreamt up a good UI for adding tags to the current filter, so at the moment I just have three drop-downs for different filters, e.g. building_type, building_technique, building_location at the top of the page and there’s currently no way (via the UI) to choose combinations of tags. The basic setup for each drop-down is this:
<txp:smd_tag_list type="article" parent="building_type" offset="1" showall="1" wraptag="ul" break="li">
<a href="/<txp:section />/filter/<txp:smd_tag_name title="0" />"><txp:smd_tag_name title="1" /></a>
</txp:smd_tag_list>
These are not wrapped in <txp:smd_if_tag_list> so the possibility to choose a tag filter is given on the normal section landing page. I guess it’s the showall attribute that’s making them show when the tag context is triggered (see note below).
Further down on the page, there is the code from the previous post which shows the in-force tags. That is wrapped in <txp:smd_if_tag_list> so it only shows if a filter is active.
… so perhaps there is a way and I’ve just been away from the plugin for too long to remember how to do it.
Me too. A few other things I noted, but haven’t investigated enough to say if they are a bug, or just a product of the way I’m using tags here:
- In the above example, if you leave out the
showall="1"I thought it would show at least the tags that have been assigned to articles but it doesn’t. - In the above example, I expected
exclude="building_type"to prevent the parent tag from being listed, but it didn’t. Usingoffset="1"skips the first tag, which is the parent. - I got confused (more probably I confused myself) by the URL name / type / trigger settings and relating that to the ‘projects’ section, so eventually ended up setting the trigger word and baking my own links manually.
- One more (unrelated) thing, while I’m at it: I’d love to be able to hide the tag panel in the write tab on a per-section basis using bot_write_tab_customize but currently the tag panel needs a wrapper and a way for bot_wtc to recognise it.
TXP Builders – finely-crafted code, design and txp
Offline
#282 2014-10-09 06:18:50
Re: smd_tags: unlimited article, image, file and link taxonomy
Is there a way of getting the total count of articles output by a smd_related_tags query? i.e. not just the number of articles assigned to a single tag, but the number of articles output when a tag combo is used. Or does smd_related_tags produce a variable with the query count that I can tap into?
I’m trying to get the total number of articles output for use with etc_pagination to work out the number of pages. I have it working fine for a single tag by storing smd_tag_count in a variable as part of “filtered by (tag-name)” notice (output using smd_tag_list) higher up the page. This I can then use to calculate the number of paged pages for etc_pagination.
I considered cumulatively adding the tag count for each of the tags using adi_calc or similar, but that won’t work in AND filter cases or in OR filter cases when an article is assigned to both tags.
TXP Builders – finely-crafted code, design and txp
Offline
#283 2014-10-09 07:25:50
Re: smd_tags: unlimited article, image, file and link taxonomy
Just in case, you can count html nodes with etc_query. If each item of smd_related_tags output is wrapped in (say) <article> tag, this will count them (and store in <txp:variable name="count" /> if needed):
<txp:etc_query name="count"
data="output of smd_related_tags"
query="count(//article)" />
If you look for the number of pages (by 10) instead of the number of articles, replace query="count(//article)" with query="ceiling(count(//article) div 10)".
Offline
#284 2014-10-09 16:59:25
Re: smd_tags: unlimited article, image, file and link taxonomy
Thanks Oleg. If smd_tags doesn’t have something in-built, I’ll give that a go. I’ve still to fully investigate the wonders achievable with your plugin but I see the logic behind your idea.
While each item has an HTML node, I’m using the limit and offset attributes in smd_related_tags with the help of your etc_offset tag to effect article-custom-style pagination for smd_tags. Won’t that falsify the results? Or do I need to simply use the smd_related_tags, once to get the total number, and again for the paginated output? I guess that adds some query overhead…
TXP Builders – finely-crafted code, design and txp
Offline
#285 2014-10-09 19:46:20
Re: smd_tags: unlimited article, image, file and link taxonomy
jakob wrote #284645:
While each item has an HTML node, I’m using the
limitandoffsetattributes insmd_related_tagswith the help of youretc_offsettag to effect article-custom-style pagination for smd_tags. Won’t that falsify the results?
They certainly will…
Or do I need to simply use the smd_related_tags, once to get the total number, and again for the paginated output? I guess that adds some query overhead…
True again. But, unless you look at the page source and adapt the appropriate db query (with smd_query or etc_query) to count articles, there seem to be no lightweight solution.
If the number of articles is reasonable, you could retrieve them all, count and then use limit and offset of etc_query to display a slice. This avoids the second query. But we’d better wait for Stef.
Offline