Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
<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)
Offline
Offline
Offline
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
Re: <txp:if_first_article> + <txp:related_articles /> ?
etc wrote #298375:
Just a thought: shouldn’t we map
related_articlestoarticle_custominstead, since it hasexcludeattribute 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.
Offline
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 likecustomfieldname.
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
Re: <txp:if_first_article> + <txp:related_articles /> ?
etc wrote #298379:
If we import
matchtoarticle_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
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
Re: <txp:if_first_article> + <txp:related_articles /> ?
I can update the docs – let me know what has changed.
Offline
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
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 itsmatchattribute (Category1,Category2by default) to also output articles related by author and/or keywords and/or custom fields to the current one. Question: ismatch="Author,%custom_field%"comprehensible enough? - Presently,
<txp:article_custom category="cat" />looks for articles withCategory1="cat" OR Category2="cat". For some reason (related to the first point), I want to introduce anew_attributesuch that<txp:article_custom category="cat" new_attribute="Category1" />would restrict the search toCategory1="cat". Question: what is an appropriate name fornew_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
Offline