Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#373 2018-02-25 09:44:15

jpdupont
Member
Registered: 2004-10-01
Posts: 752

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

Thanks Stef, I will test. Before seeing your post, I tried the new txp: evaluate. It works, see below. Is this very expensive in resources?

<ul>
<!-- QUERY 1 = the TAGS -->
<txp:smd_query query='SELECT name AS parentName, title AS parentTitle, id AS parentID 
FROM smd_tags WHERE parent ="root" AND type = "article" AND name <> "root" ORDER BY title ASC' break="">
<txp:evaluate test="smd_query"> <!-- <-----EVALUATE THE NEXT QUERY -->
<li>{parentTitle}
<!-- QUERY 2 = ARTICLES -->
<txp:smd_query query='SELECT textpattern.Title, textpattern.Status, textpattern.ID, textpattern.Body,textpattern.Section FROM textpattern INNER JOIN smd_tags_used ON smd_tags_used.item_id = textpattern.id 
WHERE Status=4 
AND smd_tags_used.tag_id = "{parentID}"  
AND textpattern.Section = "mysection" 
' wraptag="dl" class="" break=""> <!-- ADD THE  FILTER ON  "MYSECTION"-->
<dt><a href='/{Section}/{ID}/{Title}'>{Title}</a></dt>
<dd>
<txp:smd_wrap_all transform="strip_tags, cut|200|20w|&hellip;">
{Body}
</txp:smd_wrap_all>&nbsp;
<a href='/{Section}/{ID}/{Title}'><span>More</span></a>
</dd>
</txp:smd_query>
</li>
</txp:evaluate> <!-- EVALUATE -->
</txp:smd_query>
</ul>

Offline

#374 2018-02-25 10:24:06

jpdupont
Member
Registered: 2004-10-01
Posts: 752

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

After tests, your query does not work, Stef. I get a very long page, with many tags alone (without articles) and many tags + articles with duplicates.
It may be necessary somewhere “DISTINCT” ??? , but I am not a master of SQL queries …

Offline

#375 2018-02-25 11:24:16

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

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

jpdupont wrote #309424:

After tests, your query does not work, Stef. I get a very long page, with many tags alone (without articles) and many tags + articles with duplicates.

The query wasn’t to render a page it was just a raw query to demonstrate how to use the smd_tag_used table to link to articles and output a list of tags in one query. If you want to output more fields form the article, add them to the SELECT and then pull them out in your smd_query container via {replacements}.

You’re right though: it’ll need some DISTINCT clause somewhere to prevent duplicates.

Alternatively, just tweak the query I posted to get a list of unique tag names in use across the section you are interested in, then use <txp:smd_related_tags /> to display the articles associated with each one. Depending on the number of tags in use, it might be a bit expensive in terms of queries though.


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

#376 2018-02-25 12:09:29

jpdupont
Member
Registered: 2004-10-01
Posts: 752

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

Thank you Stef. I will look at the last suggestion with <txp:smd_related_tags/>.

On the other hand, is my solution with <txp:evaluate /> (which works correctly) a somewhat twisted use of evaluate, and too greedy in resource? Or the <txp:evaluate /> code optimizes all this?

Offline

#377 2018-02-25 13:23:11

etc
Developer
Registered: 2010-11-11
Posts: 5,145
Website GitHub

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

jpdupont wrote #309426:

On the other hand, is my solution with <txp:evaluate /> (which works correctly) a somewhat twisted use of evaluate, and too greedy in resource? Or the <txp:evaluate /> code optimizes all this?

The multiple queries seem expansive, and <txp:evaluate /> does not help in any way here. I would rather try to extract everything in one go as suggested by Stef, but the only way to be sure is test and look at the debug info.

Offline

#378 2018-02-25 19:06:32

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 687
Website Mastodon

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

First of all a big thank you to you, Stef, for this awesome plugin. I will make sure to meet your donation button soon again. But then

debeo wrote #302925:

If anyone would be so kind to explain probably obvious thing that I can’t grasp.

I have articles under many sections and want to show them all under particular tag to which are they assigned. What do I do with ‘URL name parameter’ if I have something like this…
<txp:smd_if_tag> <txp:smd_related_tags type="article" match="tag_name" wraptag="ul" break="li"> <txp:permlink><txp:title /></txp:permlink> </txp:smd_related_tags> </txp:smd_if_tag> ?

I am having the same problem. I display a tag tree somewhere and want to display a list of articles using a one particular tag, when clicking on that respective tag in the tree. (Bloke’s fix below your post didn’t work here).
Using smd_tags 0.60 fresh installed today on a txp 4.6.2.

I am using

<txp:smd_if_tag_list auto_detect="0" type="article"> <txp:smd_if_tag> <txp:smd_related_tags section="music" type="article" match="tag_name" wraptag="ul" break="li" /> <txp:permlink><txp:title /></txp:permlink> </txp:smd_if_tag> </txp:smd_if_tag_list>

as part of an article form.
This article is entitled “results”, has a section “filter”, which is what i told smd_tags to use to construct tag links (smd_tag_u_sec).
When i call that article i [edit…] as an article_custom with above form applied, like in <txp:site_url />/filter/article/band i get not just articles tagged with “band”, but all articles in section music (like called in form above). Though not the articles, which didn’t use any tag at all. That seems to show, that there is some recognition of the form code… [/edit]

Anyhow, a tag doesn’t seem to play a role in the detection of the results.

Is it wrong to use the smd code above as part of an article form?

Where is my error?

Last edited by jayrope (2018-02-25 23:51:15)


A hole turned upside down is a dome, when there’s also gravity.

Offline

#379 2018-02-26 14:14:24

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

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

jayrope wrote #309430:

I display a tag tree somewhere and want to display a list of articles using a one particular tag, when clicking on that respective tag in the tree.

This should be pretty standard functionality in smd_tags. First of all, a few things to note/questions:

  • When you say you display the tag tree “somewhere”, where is that exactly? In the Page template of your filtersection? How’s it being displayed? (what tag code?)
  • Why are you putting an article in the filter section and results code in an attached Form? I mean, it might work (in theory) but I’m not sure if Txp’s internal proccessing will get in the way (which might in fact have a bearing on your other query). It’ll probably depend on your use of <txp:if_individual_article> / <txp:if_article_list> and where the tag tree is displayed in the page flow.

That second point requires exploration. When Txp encounters your filter section it’ll load a given Page/Style as a “landing page” (a.k.a. list page / not an individual article page). The plugin wakes up, since the URL matches, and it’ll look at the remainder of the URL to determine if you’re viewing an individual tag:

  1. If not (example.com/filter) it should be instructed in your page template to render a tag list, either all tags, tags from a parent, used/unused/whatever. That allows visitors to click tags in the tree to see more.
  2. If individual tags are given (example.com/filter/article/tag1+tag2+tag3+...) then your page should detect this situation and use <txp:smd_related_tags> to fetch all articles that match the given tag(s).

Notice in the above two situations that under no conditions is an article called. As far as the plugin is concerned, there is no individual article view on a tag page.

So, by the time Txp gets involved – after the plugin has checked the URL status – and Txp decides to try an individual article, it’ll find your results page and dutifully render it. But all the tag stuff that the plugin set up might become confused because it’s not a list any more. I’m not sure, never really tested it that far as it’s not how I envisaged it to be used.

What you could do in situation 2 above, inside the <txp:smd_if_tag>, is put your article_custom there to load the article, display some top and tail content and then somewhere sandwiched in the middle, call the result form to display the tag contents/related articles. That might work a bit better.

<txp:smd_if_tag_list auto_detect=“0” type=“article”>

There are no such attributes to this tag. Check the plugin docs for details.

If you’re still stuck, post the relevant parts of your page/form template code and I’ll see if I can figure out what’s going on.


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

#380 2018-02-26 14:44:16

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 687
Website Mastodon

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

Bloke, thank you for coming back to this.

I display a sitemap (made from tags) in an article called sitemap, which is not part of my trigger section (the trigger section is called filter).
This is obviously my first mistake.
That sitemap/tag tree displays correctly.
The links of the tags follow the scheme site_url/trigger_section/article(from type)/tag
My landing page in the trigger section “filter” uses just a form with a content like this

<txp:smd_tag_list type="article"> <txp:smd_tag_info item="name" /> - <txp:smd_if_tag_list auto_detect="0"> <txp:smd_if_tag> <txp:permlink><txp:title /></txp:permlink> <txp:smd_related_tags section="music" type="article" match="tag_name" wraptag="ul" break="li" /> <br /> <txp:else /><txp:title /> has no tags, <txp:permlink>please edit</txp:permlink><br /> </txp:smd_if_tag> </txp:smd_if_tag_list> </txp:smd_tag_list>

I understand, that there is no article form used anywhere, so i go that way first.
… and report back. Thanx much!

Last edited by jayrope (2018-02-26 14:49:47)


A hole turned upside down is a dome, when there’s also gravity.

Offline

#381 2018-02-26 15:18:05

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

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

jayrope wrote #309444:

I display a sitemap (made from tags) in an article called sitemap, which is not part of my trigger section (the trigger section is called filter). This is obviously my first mistake.

Not necessarily. You can display tag lists anywhere you like, in any section.

What you can’t do is use the <txp:smd_if_tag_list> to query the URL and see if you’re on a tag landing page, unless you’re on the section that you’ve designated in the smd_tags prefs as the one where you process tags. If you try and use that conditional tag on any other page, the tag will just shrug its shoulders and skip past it (or always do its ‘else’ branch) because the plugin’s URL handler isn’t invoked, thus it has no frame of reference to know what a tag list page is.

The reason for this, btw, is that the URL handler is pretty query-intensive so I constrained it to run only in one place for your vistors’ sanity and PageSpeed scores :-)


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

#382 2018-02-26 15:49:11

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 687
Website Mastodon

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

Well what i had in mind is tagging all articles with as many tags as i want to, then get these lists:

1. a tree of all tags with use counts, each tag entry linking to (working here, from your Example 1 in plugin help)
2. it’s own (single tag) list containing the titles of article assigned to respective tag (not working here).

I moved both 1. and 2. into the same form in the trigger section to avoid section confusion.
Can you five me a hint for which code i should use to achieve 2.?

i suppose both 1. and 2. could be a single output_form called when accessing the filter section?

I’m confused. I was hoping to let go of categories and instead use smd_tags to be able to create a sort of ever-growing network of tags and their respective entries.

Last edited by jayrope (2018-02-26 15:54:22)


A hole turned upside down is a dome, when there’s also gravity.

Offline

#383 2018-02-26 15:51:55

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

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

jayrope wrote #309448:

I was hoping to let go of categories and instead use smd_tags to be able to create a sort of ever-growing network of tags and their respective entries.

That’s precisely what the plugin is for, so this’ll just be a configuration teething issue. I’ll try and set up my site to make it work in a similar way you have and post my code.


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

#384 2018-02-26 16:08:19

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 687
Website Mastodon

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

[Thank you, Stef, I sent you some flowers.]

Maybe it helps to know, that the plugin parts in an article write form here show “smd_tag_title” as well as [smd_tag_clear] & [smd_tag_toggle], those last two without link to them.
Confused plugin?

Last edited by jayrope (2018-02-26 16:08:46)


A hole turned upside down is a dome, when there’s also gravity.

Offline

Board footer

Powered by FluxBB