Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-03-20 21:44:04

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

<txp:if_first_article> + <txp:related_articles /> ?

In Txp 4.6 I can’t make <txp:if_first_article> work in a <txp:related_articles /> form, is it normal? It works if I use <txp:article_custom /> instead of <txp:related_articles />

Last edited by NicolasGraph (2016-03-20 21:44:59)


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

Offline

#2 2016-03-20 22:09:11

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

Re: <txp:if_first_article> + <txp:related_articles /> ?

They have never worked in <txp:related_articles />. Now they should, please test.

Offline

#3 2016-03-20 22:16:08

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

Re: <txp:if_first_article> + <txp:related_articles /> ?

etc wrote #298373:

They have never worked in <txp:related_articles />.

Ok, I never tried before…

Now they should, please test.

Perfect, thanks!


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

Offline

#4 2016-03-20 23:04:46

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

Re: <txp:if_first_article> + <txp:related_articles /> ?

Just a thought: shouldn’t we map related_articles to article_custom instead, since it has exclude attribute in 4.6?..

Offline

#5 2016-03-21 07:59:11

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

Re: <txp:if_first_article> + <txp:related_articles /> ?

etc wrote #298375:

Just a thought: shouldn’t we map related_articles to article_custom instead, since it has exclude attribute in 4.6?..

That’s right, <txp:article_custom category='<txp:category1 />, <txp:category2 />' exclude='<txp:article_id />' /> is fine now and it allows to add more restrictions with attributes like customfieldname.


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

Offline

#6 2016-03-21 08:51:40

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

Re: <txp:if_first_article> + <txp:related_articles /> ?

NicolasGraph wrote #298378:

That’s right, <txp:article_custom category='<txp:category1 />, <txp:category2 />' exclude='<txp:article_id />' /> is fine now and it allows to add more restrictions with attributes like customfieldname.

Exactly, and also author, month, etc. It only lacks match attribute to fully supersede related_articles. If we import match to article_custom, it will be possible to make <txp:related_articles ... /> just a shortcut for <txp:article_custom exclude='<txp:article_id />' ... /> — less code to maintain.

Offline

#7 2016-03-21 09:26:23

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

Re: <txp:if_first_article> + <txp:related_articles /> ?

etc wrote #298379:

If we import match to article_custom, it will be possible to make <txp:related_articles ... /> just a shortcut for <txp:article_custom exclude='<txp:article_id />' ... />

+1


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

#8 2016-03-21 15:01:49

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

Re: <txp:if_first_article> + <txp:related_articles /> ?

Bloke wrote #298380:

+1

Great! It costs nothing to extend match in <txp:related_articles /> to be able to relate also by Author, Keywords and custom fields (have I forgotten anyone?). I have quickly tested, ready to commit if ok.

Edit: but someone else would have to update the docs :)

Last edited by etc (2016-03-21 15:02:42)

Offline

#9 2016-03-21 15:15:57

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: <txp:if_first_article> + <txp:related_articles /> ?

I can update the docs – let me know what has changed.

Offline

#10 2016-03-21 15:34:04

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

Re: <txp:if_first_article> + <txp:related_articles /> ?

etc wrote #298382:

but someone else would have to update the docs :)

And history.txt needs updating too…


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

#11 2016-03-21 16:58:02

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

Re: <txp:if_first_article> + <txp:related_articles /> ?

Ok, but there are few points to settle before the history is written.

  • Presently, <txp:related_articles /> outputs only the articles having the same categories that the current article. We want to enhance its match attribute (Category1,Category2 by default) to also output articles related by author and/or keywords and/or custom fields to the current one. Question: is match="Author,%custom_field%" comprehensible enough?
  • Presently, <txp:article_custom category="cat" /> looks for articles with Category1="cat" OR Category2="cat". For some reason (related to the first point), I want to introduce a new_attribute such that <txp:article_custom category="cat" new_attribute="Category1" /> would restrict the search to Category1="cat". Question: what is an appropriate name for new_attribute?

Edit: since there are other possible SQL LIKE patterns, match="%custom_field%" would be not very general anyway. So we’d better bound ourselves to exact custom fields match.

Last edited by etc (2016-03-21 17:28:57)

Offline

#12 2016-04-11 10:51:31

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

Re: <txp:if_first_article> + <txp:related_articles /> ?

etc wrote #298386:

Question: what is an appropriate name for new_attribute?

field or match_field ?


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

Offline

Board footer

Powered by FluxBB