Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-09-07 14:45:40

jpdupont
Member
Registered: 2004-10-01
Posts: 752

How reverse an article_custom attribute value ?

I made a semi automated archiving system for a site.

I place in the archives all the articles whose expiry date has passed + all the articles whose archiving is forced by selecting an option of a select box (glz_custom_fields) including the 5 positions of an article on the site.

With article_custom I use expired="0" for the expiration date. But how to use my custom_field position_article by passing the correct attribute?
position_article="archive" is OK to select what is voluntarily archived, but I want the opposite: select what is not archived (ie one of the 4 other values of my field position_article. I wish to actually reverse this filter position_article="archive".

I see exclude in the new 4.7 attribute.
Is it possible to do : exclude="position_article='archive'"

Last edited by jpdupont (2018-09-07 14:51:19)

Offline

#2 2018-09-07 14:56:04

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

Re: How reverse an article_custom attribute value ?

jpdupont wrote #313900:

I see exclude in the new 4.7 attribute.
Is it possible to do : exclude="position_article='archive'"

You are almost there: position_article="archive" exclude="position_article".

Offline

#3 2018-09-07 16:43:33

jpdupont
Member
Registered: 2004-10-01
Posts: 752

Re: How reverse an article_custom attribute value ?

Perfect, Oleg! Thank you !
By the way, I’m going now with the new tag <txp:evaluate /> : a pleasure!

Offline

#4 2018-09-07 17:56:14

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

Re: How reverse an article_custom attribute value ?

Nice one! That’s another tidbit we need to save somewhere. Didn’t Oleg have a great “before 4.7, after 4.7” thread with similar improvements?

I recently came across a few of Oleg’s other simplifications while fixing the plugins site:

<txp:article_custom section="my_section" category="my_category" pageby="1" pgonly />

will give you the article count for your respective attribute contribution (obviating the need for mdn_count).

Bonus: changing pageby="{your_value}" will show you the number of pages of results and can be helpful to determine if you need pagination or not.

And a replacement for the ancient glx_if_frontpage and the many multiple nested if_-tags to determine whether you are actually on the front page of the entire site.

<txp:if_section name="default">
	<txp:if_article_list type="author, c, month, pg, q" not>
	 	 <!-- this is the front page of the entire site -->
	</txp:if_article_list>
</txp:if_section>

Going through the textpattern plugins site – last properly updated in 2008 – made me aware of how far we have come over the years. Many plugins have been rendered obsolete through the incorporation of an added attribute and Oleg’s seemingly mini-additions here and there have made some tags much more flexible and more powerful than they were in the past. The only thing is, they were easier to recognise as plugins (which were named to solve a problem). Now we need to recognise the power of certain attribute combinations.


TXP Builders – finely-crafted code, design and txp

Offline

#5 2018-09-08 00:40:48

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: How reverse an article_custom attribute value ?

jakob wrote #313908:

And a replacement for the ancient glx_if_frontpage and the many multiple nested if_-tags to determine whether you are actually on the front page of the entire site.

That is sweet. I am definitely going to incorporate that into my next design.

Offline

#6 2018-09-08 08:23:33

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

Re: How reverse an article_custom attribute value ?

jakob wrote #313908:

“before 4.7, after 4.7” thread with similar improvements

is here awaiting contributions. :-)

Many plugins have been rendered obsolete through the incorporation of an added attribute

Often we had no choice, e.g. mdn_count did not take into account new or modified <txp:article /> attributes. And it was two lines of code to add to core vs duplicating a large core block in the plugin.

Offline

Board footer

Powered by FluxBB