Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#301 2015-06-04 14:39:11

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

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

jakob wrote #291303:

could you achieve this in a multi-step process?

That’s the sort of thing I was thinking about before I realised that counting the tags in the main query is something the plugin should do anyway as it brings potential other benefits when combining the counts with tag lists and other content types. I’m not sure if the value is possible to output to the screen via smd_tag_info yet. I’ll look into adding that later if it doesn’t work right now.

Full marks for your innovative approach!


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

#302 2015-06-05 08:30:10

bojay
Member
Registered: 2010-04-13
Posts: 11

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

Thank you both for your quick replies.
Jakob – I like your thinking and I can totally see where you’re going. But as you mention yourself – more matches equals higher relevance, so there will be article that are matched on three or even four tags.

In reality we’re talking about board games here – and the tags are categories, mechanics and themes in games.

I’ll see if I can get the beta complied and try it out asap. Thanks.

Last edited by bojay (2015-06-05 08:36:56)

Offline

#303 2015-06-05 09:20:16

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

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

Just to note that if you only use categories, you can do it core-way:

<txp:php>
	safe_query(parse("SET @c1='<txp:category1 />', @c2='<txp:category2 />'"));
</txp:php>

<txp:article_custom category='<txp:category1 />,<txp:category2 />'
	sort="(Category1=@c1)+(Category2=@c2) DESC, RAND()" />

You can also give different weights to category matches:

sort="2*(Category1=@c1)+(Category2=@c2) DESC, RAND()"

Offline

#304 2015-06-07 20:36:07

bojay
Member
Registered: 2010-04-13
Posts: 11

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

I just gave version 0.51 a test and to start of with the bad news, something is off in terms of LIMIT=“4”, it applies the limit to each tag seperately.

<txp:smd_tag_list wraptag="" break="" >
   <div id="related">
   <txp:smd_related_tags  sort="tag_sum" limit="4" form="relatedgame" break="" />
   </div>
</txp:smd_tag_list>

I’m currently at an article with three tags – and I’m getting 12 articles back from the above. 4 matches on each tag.

I’ve setup relations so that one article is matching the same three tags as my current rendered article, and that article is (correctly and constantly) included in the returned array. So one-up for that :-)

I’ve used this to test if the same articles was constantly in the feed.

<txp:smd_related_tags  sort="tag_sum, rand()" limit="4"  />

Last edited by bojay (2015-06-07 20:40:17)

Offline

#305 2015-06-07 21:03:04

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

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

bojay wrote #291407:

in terms of LIMIT=“4”, it applies the limit to each tag seperately.

In your tag setup, it will. It’s designed that way. The <txp:smd_tag_list> tag repeats its container for every tag that matches the tag(s) in the URL or the current tag context (in this case the article). I thought what you were trying to do was find out other articles that matched the tags in the current article, in order of “most tags matched”?

I’m currently at an article with three tags

Then you shouldn’t need any more than this:

<txp:if_individual_article>
   <txp:smd_related_tags limit="4" sort="tag_sum desc, Posted desc" />
</txp:if_individual_article>

That will look at the article’s current tag set and find any other articles that match those, showing 4 articles in descending order of number of matches. So if the article’s three tags were:

  • Rod
  • Jane
  • Freddy

and you had two other articles (in the same Section in this case) with exactly the same three tags, they’d get shown first because they’re a “stronger” match. Next in the list would be any articles that matched (any) two of the three tags, and so on, until you hit the limit. Have I misunderstood what you want to achieve?


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

#306 2015-06-07 22:09:15

bojay
Member
Registered: 2010-04-13
Posts: 11

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

Thanks Stef,
Off cource – you’re right, it was reminisce from when I was trying to run through all tags and do something clever with the return. My Bad !

Your description fits what I’m trying to achieve. And It works nicely !!

I think the “desc” in

sort="tag_sum desc, Posted desc"

is the thing making a difference now, because the strongest match is the higher score ?

Offline

#307 2015-06-07 22:38:31

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

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

bojay wrote #291409:

It works nicely

Ace.

I think the “desc” is the thing making a difference now, because the strongest match is the higher score ?

Yes. What the plugin does is tot up the number of tags that each article has in common with the current one. So in your case, any articles that match all three tags in the current article get a tag_sum “score” of 3. If they only match two, their score is 2, and so forth. Sorting in descending order of this result therefore puts the higher scores first. Using tag_sum desc, Posted desc will choose newer articles over older ones too, as a secondary sorting option.


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

#308 2015-06-14 14:24:55

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

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

Hi,
I have two problems with the use of the plugin which are probably easy to solve but I didn’t find how for now:

  1. The trigger section is always the first of the prefs list but I would like that the tag calls the current section each time it is clicked to display the related articles listing (i.e. /current-section/article/tag-name);
  2. on the tag list page, one article is missing on each listing.

Thanks for your help…

Edit: solved!

Last edited by NicolasGraph (2015-06-14 16:28:12)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#309 2015-06-29 06:33:25

mmelon
Member
Registered: 2006-03-02
Posts: 95

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

Hi

i’ve recently updated to 4.5.7. When I install the plugin it appears to work okay, but visiting the trigger section gives

general_error Notice: Undefined offset: 2 on line 2640
smd_tags_url_handler()
textpattern/lib/txplib_misc.php:854 call_user_func_array()
textpattern/publish.php:221 callback_event()
textpattern/publish.php:128 preText()
index.php:82 include()

Interestingly it didn’t ask me to install any tables. Also some of the css looks a little wonky on the Hive admin theme.

Any ideas what I might be doing wrong?

Mike

Offline

#310 2015-06-29 07:48:08

mmelon
Member
Registered: 2006-03-02
Posts: 95

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

Permlink mode is section/title

Offline

#311 2015-06-29 14:39:30

mmelon
Member
Registered: 2006-03-02
Posts: 95

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

I think i was just using the plugin incorrectly. i still don’t really get how url tag combinations work. Using this code

<txp:smd_if_tag>
   <txp:smd_tag_list wraptag="" break="">
      <txp:smd_related_tags wraptag="ul" break="li" />
   </txp:smd_tag_list>
<txp:else />
   <txp:article form="simple" />
</txp:smd_if_tag>

I can match an article on a tag like – filter/red

However if the article is tagged with apple, red, small, I would expect – filter/apple/red/small (after changing the AND combinator symbol) to only return that article once. That makes sense as we want only articles that match all three. It is giving me back the article three times, like it is being evaluated against each tag in the url sequentially. Have I misunderstood how the AND symbol works in the url? If so can i get the behaviour formerly mentioned from this plugin?

Essentially I am trying to build a filter search. Seems to me I can do that with a series of checkboxes that add/remove /red, /blue etc etc on tick/untick. So if I built the url filter/red/blue, can it only return articles tagged with both, and only return them once?

Hope that make sense.

Mike

Moderator’s annotation:
Edited to add Textile’s bc. for visible indentation.
– Uli –

Last edited by uli (2015-06-29 14:44:38)

Offline

#312 2015-06-29 15:57:10

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

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

mmelon wrote #292270:

i still don’t really get how url tag combinations work.

I’ll admit it’s a little confusing, but the essence is that if you use <txp:smd_tag_list> it iterates over the tags in the current context (URL, mostly) if on a tag landing page.

So, if you wrap your <txp:smd_related_tags> tag in a tag list, you’re looping over each tag in your URL and passing it to the container, one by one. Hence you’ll get repeated results, because it’ll look for all articles related to tag1, then all articles related to tag2, and so on. That’s irrespective of the “mode” that your URL suggests (and/or): it just looks in the URL and treats each tag as a unique item.

If you take away the <txp:smd_tag_list> tag then the issue should go away and it’ll work as you expect. Viz:

<txp:smd_if_tag_list>
   <txp:smd_related_tags section="articles" wraptag="ul" break="li">
      <txp:permlink><txp:title /></txp:permlink>
   </txp:smd_related_tags>
</txp:smd_if_tag_list>

So if you set your AND combinator to / and build up your URLs either like this:

example.org/smd_tags/tag1/tag/2/tag3

or force article context:

example.org/smd_tags/article/tag1/tag/2/tag3

it’ll AND all the tags together and only return you articles that match all three.

At least, that’s what it’s supposed to do!


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

Board footer

Powered by FluxBB