Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2015-07-27 03:00:59
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Expired moan
Consider the following scenario:
Preference “Publish expired articles?” set to No.
Article tag:
<txp:article expired="1">
<txp:title />
</txp:article>
Generates titles for all articles, both expired or otherwise.
Add in if_expired
:
<txp:article expired="1">
<txp:title />
<txp:if_expired>EXPIRED</txp:if_expired>
</txp:article>
Still get all articles, but now for each one there’s an error message:
Tag error: <txp:if_expired> -> Textpattern Notice: publish_expired_articles_prefs_off while parsing form None on page test
textpattern/publish/taghandlers.php:2047 trigger_error()
if_expired()
textpattern/vendors/Textpattern/Tag/Registry.php:80 call_user_func()
textpattern/lib/txplib_publish.php:477 Textpattern_Tag_Registry->process()
textpattern/lib/txplib_publish.php:398 processTags()
textpattern/publish.php:950 parse()
textpattern/publish.php:1050 doArticles()
textpattern/publish.php:673 parseArticles()
article()
textpattern/vendors/Textpattern/Tag/Registry.php:80 call_user_func()
So the questions are:
- Why does TXP throw an error when I’ve explicitly told the tab to output expired articles
- Is there any point to the error message anyway?
- Am I just confused?
Offline
Re: Expired moan
You are forbidden to show expired articles, and they are showing themselves, and therefore get a warning (not error).
TxP code:
if (!$publish_expired_articles && $production_status != 'live') { trigger_error(gTxt('publish_expired_articles_prefs_off'), E_USER_NOTICE); }
Although I do not see the point of this warning. Output of articles occurs without warning, and the warning is issued only if_expired
. I would have removed the warning.
aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)
Offline
#3 2015-07-27 06:44:23
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: Expired moan
makss wrote #293713:
You are forbidden to show expired articles, and they are showing themselves, and therefore get a warning (not error).
TxP code:
if (!$publish_expired_articles && $production_status != 'live') {...
Although I do not see the point of this warning. Output of articles occurs without warning, and the warning is issued only
if_expired
. I would have removed the warning.
Yes, I’d expect that explicitly asking for expired articles (expired="1"
) should override any complaints.
Offline
Re: Expired moan
Another thing, this code is executed without any warning and generated links to articles already expired.
<txp:article_custom expired="1"> <txp:permlink><txp:title /></txp:permlink> </txp:article_custom>
Textpattern for expired articles return code 410. It makes no sense to refer to such articles.
I think need to <txp:permlink />
to issue a warning for expired articles (if $publish_expired_articles == ‘no’) and/or not return link to expired article.
Warning inside if_expired
meaningless. Many sites show titles of past events or actions, and why not? But to put invalid links (<txp:permlink />
) to them is not necessary.
Last edited by makss (2015-07-27 09:37:22)
aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)
Offline
Re: Expired moan
Does seem a bit odd to throw a warning. Guess it comes down to whether a tag attribute should override a pref. Would you please be able to put forward a patch that makes this work sensibly, makss?
In theory, the article
tag doesn’t accept expired
as an attribute, but due to its close ties with article_custom
it does silently accept them. And the same issue affects article_custom anyway.
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
#6 2015-07-27 22:06:57
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: Expired moan
Bloke wrote #293748:
Hi Stef & makss, thanks for looking into this.
Does seem a bit odd to throw a warning. Guess it comes down to whether a tag attribute should override a pref.
Isn’t expired="1"
already overriding a pref?
In theory, the
article
tag doesn’t acceptexpired
as an attribute, but due to its close ties witharticle_custom
it does silently accept them. And the same issue affects article_custom anyway.
Yes I was just being lazy and keeping the example code short … hopefully one day the article
/ article_custom
quirkiness might be a thing of the past.
Offline
Re: Expired moan
gomedia wrote #293755:
Isn’t
expired="1"
already overriding a pref?
Sort of yes. Just not doing a very good job of it.
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 2015-07-27 22:50:28
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: Expired moan
Bloke wrote #293756:
Sort of yes. Just not doing a very good job of it.
I think it’s doing a fine job … by providing additional functionality. It’s just the “Tag error:” whinging that needs to disappear!
Offline
Re: Expired moan
Pull request: Remove unnecessary warning in if_expired tag
Pull request: Avoid links to expired articles
- For expired articles is returned link to
site_url/#expired_article
- Show warning
permlink_to_expired_article
ifproduction_status != 'live'
aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)
Offline
Re: Expired moan
makss wrote #293780:
- For expired articles is returned link to
site_url/#expired_article
I’d rather continue to adhere to the HTTP protocol using a ‘410 Gone’ response.
Offline
Pages: 1