Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 Yesterday 00:12:12

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

New tag: if_article_status

Please try <txp:if_article_status> (commit).

Takes one attribute status which defaults to live. If you use it valueless it mimics the <txp:article> usage and will match live, sticky. Otherwise you can specify a list of status names/values to match, and if the current article has one of those statuses, the contained content is executed.

Supports <txp:else /> and not.

Feedback welcome.


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

#2 Yesterday 05:00:46

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,926
Website GitHub

Re: New tag: if_article_status

Excellent, and a logical complement to the recently added ability to use txp:article_custom for other statuses. Also expands on Robert’s wet_if_status, which can be retired now. Thanks!


TXP Builders – finely-crafted code, design and txp

Offline

#3 Yesterday 09:49:41

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

Re: New tag: if_article_status

Thanks for checking it out. Yes, it occured to me that the ability to check status hasn’t kept step with the expansion to sticky and live many years ago. With pending added to the mix, it made sense to me.

I haven’t explicitly outlawed checking for draft and hidden, though they won’t do anything in core because those articles can’t be displayed. But if you, for example, introduced a plugin that could allow it for whatever reason, the tag could be used as long as $thisarticle is populated appropriately.

If people think we should outlaw checking non-publishable statuses entirely, it’s a one-line change to prohibit them. Thoughts appreciated.

Edit: and if you have a plugin that adds more status values, you can test for them with the tag. In theory. Untested but it should work, if you use the status_list callback to add them.

Last edited by Bloke (Yesterday 09:52:27)


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

#4 Yesterday 16:33:46

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,174
Website GitHub Mastodon Twitter

Re: New tag: if_article_status

Although not needed for our sites, I guess we could think of other statuses. One that we keep having requests in the forum is a “members-only” access to some content. So we can add status restricted and figure out how we can employ that one out of the box, without having plugins and/or hacks for just “reading” members.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#5 Yesterday 17:13:37

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

Re: New tag: if_article_status

Well I don’t know about “without plugins”. You’d need a 3-line plugin to hook into the status_list callback and add the Restricted status, with a number of your choosing. But then, yes, after that if all your members have logins of a particular level (or a new level If you employ smd_user_manager) you could use <if::logged_in group="your-role-name">
<txp:article_custom status="restricted">.

Or you could show your logged in members more content in your regular article tag flow if you use status as above and then wrap the if_logged_in and if_article_status conditionals around each row so they only show restricted articles to members.


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