Textpattern CMS support forum

You are not logged in. Register | Login | Help

#31 2009-01-15 03:10:51

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 981
Website

Re: smd_tags: unlimited article, image, file and link taxonomy

Thanks so much for your detailed reply! I know what it’s like to be snowed under by client work, and I don’t blame you for minding your priorities.

Everything up to this point is working fine:

site.com/smd_tags/article will show all article tags and — if they share any tags with files — will show those too as a list.

Check!

site.com/smd_tags/file will show all file tags and — if they share any tags with other files — will show those too as a list. And so on.

Don’t have any files, so I get a warning: Notice: Uninitialized string offset: 0 on line 1399. This, I don’t mind so much.

site.com/smd_tags/article/tiger will show the article tag ‘tiger’ and — if any files also have the tag “tiger” — will show those as a list.

This url (using a valid article tag in place of tiger) returns error 404. If I omit the /article url segment, I get the tag list again, displaying perfectly.

In this way, you can construct URLs that allow you to browse tags in a way that makes sense to your visitors. For example, if you have a traditional article and have tagged it with tiger big stick poke roar chomp ouch hospital you could list all the tags under your article in your article form:

<txp:permlink><txp:title /></txp:permlink> Filed in: <txp:category1 link="1" title="1" /> Tags: <txp:smd_tag_list><txp:smd_tag_name link="1" title="1" /></txp:smd_tag_list>

That makes a clickable link from each tag to your default tag section.

Check! This works flawlessly for me.

So, in theory (you’ll see why in a sec) if you click on “roar” it will take you to the URL site.com/smd_tags/article/roar and on that Page you can do whatever you want: list other articles with the same tag, list other files that share the tag (like the example above), list other links that have the same category as the given tag. The sky’s the limit.

Well, it would be, except I think the URL scheme is broken :-( At least it’s broken in my dev copy. It might be because I killed it with something I did as I’m developing v0.2 or it could be that it’s also broken in v0.11.

I think that’s the case in the version I’m using. Clicking on any links generated by the link="1" attribute leads to the tags section, but no content there.

Behind the scenes the plugin is supposed to figure out what that means and present the correct list as if you’d done it with a clean URL. But I don’t know if it does. If not you can still make it work by manually constructing clean URLs in your anchors, but it’s a hassle you could do without. Taking the current permlink mode into account is slated for v0.2 (now I understand it all a bit more!)

How would I construct a clean url that would show me a list of articles matching a certain tag? I find I can usually construct something once and drop it into a form for reuse.

If I turn off tag links, I can still display article tags on the article, and make use of smd_related_tags to show related articles. I don’t have “browse by tag” functionality yet, but I don’t mind holding off on that until the next version is out, or sooner if someone can identify what I’m doing wrong.

YMMV: it might work as indicated above or may not. I know of a few other people using v0.11 and they’ve not complained so perhaps it is working; or perhaps they’re not using it in this way.

I’d love to hear from others using the plugin to find out if and how they’ve implemented browsing by tag.

If it doesn’t work I will do my level best to get v0.2 out asap. I’m snowed under with a client site right now but should be clear in a few weeks. I know I’ve been promising this one for ages and I’m sorry it’s not quite all there but I’ll try and get this darn plugin singing like it should as soon as I can.

Does that give you any ideas or have I completely flummoxed you now? :-)

Immensely helpful, thank you! I’m very grateful for your help, and I think I have a marginally better grasp of how it will work!

Offline

#32 2009-01-15 05:51:03

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 981
Website

Re: smd_tags: unlimited article, image, file and link taxonomy

The only thing I miss from tru_tags is that it pulled double duty for meta keywords on individual articles. Is there a way to automate duplicating your tags as keywords? The easiest option I’ve found is to use the textarea input option and copy and paste. I’m probably the only one who would ask for this feature, so take it with a grain of pepper.

Thank you again for the awesome plugin!

Offline

#33 2009-01-15 06:40:15

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 981
Website

Re: smd_tags: unlimited article, image, file and link taxonomy

Sorry to trouble you again, I didn’t imagine this would be a problem:

How do I set smd_related_tags to only output articles with “live” status? Textpattern’s native tags naturally exclude sticky content unless called to do so. I’m getting links to sticky articles included in the mix, but the links go to no content: Here’s an example: Under “Possibly Related,” there’s a link to “A blog about peacebuilding, social marketing & visual storytelling”, which is the sticky article on the blog’s landing page.

My default page uses this to distinguish if you’re on a section landing page or an individual article:

<txp:if_article_list>
	<txp:article limit="1" status="sticky" />
	<txp:else />
	<txp:article />
</txp:if_article_list>

As a result, there’s no content at http://designop.us/wrote/updated-every-year-whether-it-needs-it-or-not. That way, the section-page content lives in one place, and I like that.

My related articles tag looks like this:

<txp:smd_related_tags type="article" section='<txp:section />' label="Possibly related" labeltag="h3" wraptag="ul" break="li" />

Since smd_related_tags doesn’t accept a status="live" attribute, I’m not sure what to do. The default behavior of most native tags seems to be ignoring sticky content unless there is a specific declaration.

EDIT: I changed my default page as a stop-gap until I figure out how to exclude sticky articles from related content— now my default page includes an extra line: <txp:article status="live" /> ↩ <txp:article status="sticky" />. This creates duplicate content, but I’m not sure what else to do.

Last edited by johnstephens (2009-01-16 21:03:15)

Offline

#34 2009-01-19 00:41:49

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,524
Website

Re: smd_tags: unlimited article, image, file and link taxonomy

johnstephens wrote:

Don’t have any files, so I get a warning: Notice: Uninitialized string offset: 0 on line 1399.

Thanks for the report. I think I’ve fixed that in the next release but I’ll verify it.

This url (using a valid article tag in place of tiger) returns error 404. If I omit the /article url segment, I get the tag list again, displaying perfectly.

Arse. OK, I’ll try and find out why that’s misbehaving. Works for me. *ponder*

Clicking on any links generated by the link="1" attribute leads to the tags section, but no content there.

As I suspected: the URL scheme is brain dead. Apologies, I’ll get that in order.

How would I construct a clean url that would show me a list of articles matching a certain tag?

In theory it’s just <a href="site.com/your_nominated_tag_section/tag_type/tag_name">Filter time!</a> but for some reason it doesn’t seem to work on your system, despite working on mine. Will do some digging.

I’d love to hear from others using the plugin to find out if and how they’ve implemented browsing by tag.

Me for one! I’ll try and distill some examples from my working test site when I get a chance and post them here for you to try. It may well be because I’m running the latest dev snapshot though and I’ve probably fixed the obvious stuff.

Is there a way to automate duplicating your tags as keywords?

Not keywords as in “they go in the keywords box in the Write tab” but you can probably cajole smd_tag_list into something like this (untested):

<meta name="keywords" content="<txp:smd_tag_list wraptag="" break=","><txp:smd_tag_name /></txp:smd_tag_list>" />

Or some equivalent functionality to show lists of tags that you can pretend are keywords!

I’m actually rethinking the client tags a bit based on stuff I learned while doing smd_calendar to make the defaults a bit more logical and allowing you to do more flexible stuff with them. That should make the tag cloud much easier to write as it’s just an extension of smd_tag_list with some custom weighting that you can control.

Also on the cards is a converter to copy your article tru_tags or rss_unlimited_catgeories into smd_tags so you can experiment with them all and see which you prefer.

To actually copy the smd_tags to the keywords field, erm, I dunno. Hadn’t really considered it. If there’s a business case for it, I’ll find a way!

How do I set smd_related_tags to only output articles with “live” status?

Yikes, that’s a collosal oversight on my part. Sorry about that. I’ll add a status filter to that (and other) tags. Thanks for letting me know about this one.

For now you can hack the plugin to do what you want. In smd_tags_client, scroll down to just over halfway (probably around lines 380-390) and look for:

case "article":
  $rs = getRows("SELECT " ........

A couple rows further on you’ll see a line starting:

WHERE tu.type='article'" . $excludeClause .....

Change it to:

WHERE tu.type='article' AND Status=4". $excludeClause .....

That should keep those article in check until I can fix it!

Many thanks for testing this and putting up with my crappy code. It’s embarrassing that it’s so full of holes, but if it wasn’t for good people like you willing to put it through its paces I’d never find half the problems, so a big big thank you. When I get clear of this client site (hopefully in a few weeks) I’ll turn my full attention to this plugin.


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

#35 2009-01-19 20:12:03

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 981
Website

Re: smd_tags: unlimited article, image, file and link taxonomy

Thank you again for your detailed support!

Bloke wrote:

In theory it’s just <a href="site.com/your_nominated_tag_section/tag_type/tag_name">Filter time!</a> but for some reason it doesn’t seem to work on your system, despite working on mine. Will do some digging.

I wanted to report back to you on this, since I saw something that might be interesting. I set up my 404 page to parse the txp:page_url request_uri into a search box, using rah_replace to knock out common delimiters such as -, +, and %20— the idea was that a mistyped url string might have words in it that would be useful in a search (with smd_fuzzy_find enabled).

With my tags section named “tags”, my url name parameter called “keyword”, and my type parameter called “select”, I entered the following url, according the the clean url pattern above: http://designop.us/tags/article/textpattern

But the search box parsed in the request_uri as this: tags?keyword=textpattern amp;#38;select=article

I take that to mean the plugin is obviously doing something!

Not keywords as in “they go in the keywords box in the Write tab” but you can probably cajole smd_tag_list into something like this (untested):

<meta name="keywords" content="<txp:smd_tag_list wraptag="" break=","><txp:smd_tag_name /></txp:smd_tag_list>" />

Or some equivalent functionality to show lists of tags that you can pretend are keywords!

Cool, this is what I did, kind of. Right now I’m using rah_metas, and if there’s nothing in the keyword field for an article it appoints default keywords. Right now I have it setup like this for section landing pages:

<txp:rah_metas
	description='<txp:article limit="1" status="sticky"><txp:rss_auto_excerpt striptags="1" excerpt="subtitle" showlinkwithexcerpt="0" /></txp:article>'
	keywords='<txp:article limit="1" status="sticky"><txp:smd_tag_list wraptag="" break=", " indent=""><txp:smd_tag_name title="1" /></txp:smd_tag_list></txp:article>'
/>

Also on the cards is a converter to copy your article tru_tags or rss_unlimited_catgeories into smd_tags so you can experiment with them all and see which you prefer.

That would be very cool— Design Opus is my only site running on smd_tags right now, and one of my client sites is running on tru_tags with a immense amount of data. Being able to import tru_tags/keyword field data would be essential if we wanted to begin using this plugin instead.

Going the other way— sending smd_tags to the keywords field —would be awesome too. If there was a one-click way to dump each articles tags into keywords (all at once from the smd_tags preference pane), that would make them more interoperable. I don’t know if there’s a business case for it, though.

How do I set smd_related_tags to only output articles with “live” status?

Yikes, that’s a collosal oversight on my part. Sorry about that. I’ll add a status filter to that (and other) tags. Thanks for letting me know about this one.

For now you can hack the plugin to do what you want. […] That should keep those article in check until I can fix it!

Awesome— implemented and gorgeous! Thank you!

Many thanks for testing this and putting up with my crappy code. It’s embarrassing that it’s so full of holes, but if it wasn’t for good people like you willing to put it through its paces I’d never find half the problems, so a big big thank you. When I get clear of this client site (hopefully in a few weeks) I’ll turn my full attention to this plugin.

I’m just happy to list related articles on a more granular basis than category!

Offline

#36 2009-01-26 14:58:45

woof
Member
Registered: 2004-08-01
Posts: 128

Re: smd_tags: unlimited article, image, file and link taxonomy

Nice plugin Stef. The tag nesting is great. I’m giving it a go and have a question re: use of the “parent” attribute:

I have my tags set up along these lines:

years
-2007
-2008
-2009
locations
-new york
-london
-paris
-munich

etc, etc

I have an article tagged with “london” and “paris” and am using the following in my article form:

<txp:smd_tag_list type="article" parent="locations"> <txp:smd_tag_name link="1" title="1" /> </txp:smd_tag_list>

I would expect this to output “London, Paris” but no, its blank. However if I go back and ensure it is also tagged with the parent “locations” …it works perfick.

Is this correct behaviour? — IE is it necessary to tag an article with a parent tag in order to display child tags? — or am I doing something wrong?

Last edited by woof (2009-01-26 14:59:31)

Offline

#37 2009-01-26 15:11:18

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,524
Website

Re: smd_tags: unlimited article, image, file and link taxonomy

woof wrote:

I would expect this to output “London, Paris” but no, its blank. However if I go back and ensure it is also tagged with the parent “locations” …it works perfick.

Balls, it’s probably a bug; it’s supposed to work as you describe. If I find a simple fix, I’ll post it here so you can carry on working until I get a chance to release the next version.

In the meantime I’ll add it the list of things to check I’ve squashed next week. Thanks for the report.


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

#38 2009-02-08 11:05:29

jakob
Moderator
From: Germany
Registered: 2005-01-20
Posts: 3,253
Website

Re: smd_tags: unlimited article, image, file and link taxonomy

Hi Stef, I’ve been experimenting with smd_tags and am too having problems with the client side tags on article list pages, or maybe I am missing something fundamental, which is quite possible. The install and admin-side stuff works just fine (cool with auto-complete), as does outputting the list of tags that are assigned to an article – the “filed under:” in an article form.

The link="1" generates messy links correctly according to the settings in the prefs, but these are not recognised on the article list page, only clean url’s such as /section/article/tag-name or /section/article for all tags (for the moment I made it form clean links manually). Note that just /section/tag-name seems to work too, and this seems to interfere with txp’s normal url-scheme as I can’t get any individual article pages to show. This latter might be part of the problems mentioned earlier. I’ve tried all manner of manual messy entry, e.g. ?tag=mytag&tag_type=article etc. but with no response.

What I am trying to achieve is a list of projects that can be filtered by tag in the same way as one uses categories, e.g.

No tag: /section/ = Section heading – list of all projects – list of all available tags to choose from in that section
With tag: /section/tag-name = Section heading with tag name and count – list of projects with that tag – list of all available tags to choose from in that section.

This is my code to do that:


<!-- heading -->
<h2>
  <txp:section title="1" />
  <txp:smd_tag_list limit="1" wraptag="" break=""> &rsaquo; <txp:smd_tag_name title="1" /> : <txp:smd_tag_count wrapcount=""/>Projekte</txp:smd_tag_list>
</h2>


<txp:smd_if_tag_list>  <!-- when tag is set -->

<!-- project list -->
   <ul id="projekt_list">
    <txp:smd_related_tags section="projekte" wraptag="" break="">
        <li><txp:permlink><txp:title /></txp:permlink></li></txp:smd_related_tags>
   </ul>

<!-- tag list -->
  <h4>Tag list</h4>
  <txp:smd_tag_list>
    <a href="/projekte/<txp:smd_tag_name />"><txp:smd_tag_name title="1" /></a><txp:smd_tag_count />
  </txp:smd_tag_list>

<txp:else />  <!-- when NO tag -->

<txp:article form="projekt_profil" listform="projekt_liste" />   

</txp:smd_if_tag_list>

My questions:

  1. Does the tag section have to be a separate section? If I set it to the same section as my articles, I can no longer call up the individual articles as mentioned above. Presumably it’s looking for a tag with the name of the article_url_title and returning none. Ideally, I’d like to use tags in separate sections (e.g. for projects and for publications) where a common tag-handling page would not be appropriate.
  2. In the heading I want to show the currently active tag (e.g. like one would use <txp:category title="1" /> for the active category). <txp:smd_tag_name title="1" /> doesn’t return anything unless it is within <smd_tag_list>. Using limit="1" works okay, except when all the tags are showing using /section/article as it (correctly) only returns the first one.
  3. How does <smd_if_tag_list> work? I seem to be able to use the various smd_tag functions whether or not it is there.
  4. Am I right in my use of <txp:smd_related_tags>? It seems to me, that this is the tag-sensitive equivalent to txp:article and produces correct output too when a tag is selected. If so, the name of the tag feels misleading to me. Perhaps something like smd_tagged_items or smd_tag_filter?
  5. In the tag list at the bottom I want to see a list of all the tags to choose from (e.g. where one would normally use txp:category_list or txp:article_custom to ignore the context) but I see only the one currently active in the url. Only when I use the url /section/article do I receive them all as one would expect, but the project list is then also not filtered. I guess this is the as-yet-incomplete smd_tag_cloud function?

Maybe I have some fundamental thinking mistake in there or am using the tags incorrectly? If so, I’d be most grateful if you could point me in the right direction.

Finally, I’m working with v4.08 on an otherwise naked test setup (no other plugins installed).


TXP Builders – finely-crafted code, design and txp

Offline

#39 2009-02-08 20:42:55

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,524
Website

Re: smd_tags: unlimited article, image, file and link taxonomy

jakob wrote:

I’ve been experimenting with smd_tags and am too having problems with the client side tags on article list pages

They are a bit broken, I admit. And I don’t know why because I swear it was working when I released it… (around mid-4.0.7 release cycle). I must be going mad because it was working for me then, but you’re right, now it definitely is not :-(

The link="1" generates messy links correctly according to the settings in the prefs, but these are not recognised on the article list page

Bug. Was working, not any more for reasons of a mystical nature. johnstephens also had the same issue. Clean URLs will be fixed now I understand them a little better. I’ve no idea why messy URLs are being ignored. It’s supposed to work, which is the very reason for the existence of those last three plugin preferences. *shrug* All I can do is apologise that this heinous error slipped through my usually dolphin-friendly testing net.

No tag: /section/ = Section heading – list of all projects – list of all available tags to choose from in that section <snip>

Your code is (almost) sound. Using smd_if_tag_list in your nominated tag section — or any section, if you use the section / section_link attributes of smd_tag_name / smd_tag_list to force tags to appear on a different page — is supposed to allow you to differentiate between regular articles and tags.

Again, I tried this and had it working on a test site but a gremlin crept in before release and must have broken it. The reason for me saying ‘almost’… see Q4 below.

1) Does the tag section have to be a separate section?

No. The one in prefs is the default. You can override this with section / section_link attributes and use smd_if_tag_list to differentiate… in theory. But beware: in the same way that TXP cannot render a category list in clean URL mode if viewing a section, you cannot use clean URL mode for tags either. For example, TXP cannot successfully differentiate between these:

site.com/articles/my-great-article
site.com/articles/my-tag-type/my-tag

In both cases, TXP will look for an article (called my-tag-type in case #2). But you can (ahem, should) be able to do this:

site.com/my-tag-type/my-tag
site.com/articles?smd_tag_type=my-tag-type&smd_tag=my-tag
site.com/tag-section/my-tag-type/my-tag
site.com/tag-section?smd_tag_type=my-tag-type&smd_tag=my-tag

The first two would require <txp:smd_if_tag_list> wrappers.

2) <txp:smd_tag_name title="1" /> doesn’t return anything unless it is within <smd_tag_list>.

Correct, it is context sensitive. The context is derived from the current smd_tag_list parameters but it should be derived from the URL parameters, if present. Again, this has me baffled because the whole point of the complicated context assignment code in the plugin is for preciesely this scenario. Leave it with me.

3) How does <smd_if_tag_list> work?

It’s only real purpose is if you wish to render lists of tags via the URL params, on a page that is not the default one set up in the plugin prefs. At all other times it is redundant, though there is no harm including it as a wrapper.

4) Am I right in my use of <txp:smd_related_tags>?

Yes and no. It too is context sensitive. Your usage here is correct (the caveat being that the URL scheme is broken) but it can go beyond this, which is why it is called related tags. It is more like txp:related_articles but for tags and all content types.

The default is to find related stuff based on the “current” tag, i.e. based on the current context: it could be the one in the URL, or one from the current article in an article list, or maybe the current file in a file_download_list. It will return a list of all things of the given type that have the same tag. The type defaults to the current context as well, so if you are viewing articles it goes and looks for other articles; if viewing links it finds other links with the same tag, and so on.

But you can change that so you can look for other stuff. e.g. :

  • other files that share the same tag as the current article
  • other articles that share a tag with the current file
  • other articles that have a tag name the same as the current article’s category1
  • other links that have a category that matches the current article tag

So it goes way beyond txp:article, txp:article_custom and even txp:related_articles and was the primary reason for the plugin’s inception in the first place. I wanted to be able to show people, say, a file download and offer other downloads that might be similar. Or other articles that contained content that was similar to the file they were viewing. Categories alone were too restrictive.

Imagine a record label web site: if someone landed on a “downloads” page that listed all your artists and they clicked a particular track to preview, you could offer links to other articles about that artist (perhaps they contain tour dates / album promos / desktop graphics / etc) or show links to other sites (e.g. their myspace page or somewhere you can see videos). And all this can be controlled automatically by a tag mechanism that can interact with other database fields such as category, description, custom fields, and so on.

It is the lifeblood of the plugin (if only it was reliable). But perhaps smd_tag_filter would be a better name, not sure. Suggestions on a postcard to the usual address!

5) In the tag list at the bottom I want to see a list of all the tags to choose from

Yeah, because all tag tags(!) are context sensitive you will always only see the ones that relate to the current context. You can override this in my dev version so you can “break out” of the context if you wish. On a non-default tag page you should be able to simulate this by using an smd_tag_list outside the <txp:smd_if_tag_list> container because the context is ‘forgotten’ outside the list:

<txp:smd_if_tag_list>
  <txp:smd_tag_list>
    <txp:smd_tag_name /> [<txp:smd_tag_count />]
    // Do some other stuff in the context of the current URL tag
  </txp:smd_tag_list>
</txp:smd_if_tag_list>

// List all other article tags availabe
<txp:smd_tag_list type="article">
  <txp:smd_tag_name link="1" /> [<txp:smd_tag_count />]
</txp:smd_tag_list>

Does that make sense?

I guess this is the as-yet-incomplete smd_tag_cloud function?

Kind of. That would be a way out, but I’m thinking of combining the tag_cloud into the tag_list because a tag cloud is really a specialised tag_list with various weighting algorithms applied. I’ve not really devled into this yet because I want to get the core functionality working properly first. If it complicates the tag_list too much then I’ll offer a separate tag, probably for convenience (it may well use the same logic of smd_tag_list but I’ll package it up to look like two distinct tags).

I’m working with v4.08

Apologies for the TXP warnings then. Plenty of them, since the new columns appeared in the textpattern table *sigh*

In a very big nutshell, the plugin is FUCT and needs some lovin’ to restore it to a time when I actually had it working sweetly and also with the new stuff I want to bring to the table. That’ll take a bit of time, but I should be able to get to it sometime towards the back-end of this week and begin to re-ravel the pieces.

Sorry it’s not living up to your expectations. Will try harder next time…

Last edited by Bloke (2009-02-08 20:43:32)


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

#40 2009-03-03 21:18:05

Hennie
Member
From: Nederland
Registered: 2009-02-06
Posts: 18
Website

Re: smd_tags: unlimited article, image, file and link taxonomy

Is there someone who has succesfully implemented smd_tags with images? I can make additional tags (hoera!), but how can I display them by tag?

Offline

Board footer

Powered by FluxBB