Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2021-05-10 10:01:02

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

Pageless sections content can't be called via article_custom?

Hi.

I have the following snippet to call the current year, either by PHP or (if PHP tags on pages are disabled in prefs), via a custom field tag…

<txp:variable name="year"><txp:evaluate query='<txp:php />'><txp:php>echo date('Y');</txp:php><txp:else /><txp:article_custom fields="max(posted)"><txp:posted format="%Y" /></txp:article_custom></txp:evaluate></txp:variable>

However, I’ve discovered that if PHP tags disabled and the only articles for the site are stored in a pageless section, then the <txp:article_custom fields="max(posted)"> is empty.

Is the intended behaviour? Seems to work fine if I have articles in any other section – so it’s the pageless section that is causing this.

Offline

#2 2021-05-10 10:06:51

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,358
Website GitHub

Re: Pageless sections content can't be called via article_custom?

I’m not sure what happens if you specify <txp:article_custom> without giving it more info about where you want to get the articles from. What happens if you add section="your_pageless_section" to the tag?


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

#3 2021-05-10 10:13:40

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

Re: Pageless sections content can't be called via article_custom?

That works – but <txp:article_custom> should be default retrieve articles from all sections unless narrowed by using a section attribute, according to our documentation.

Since I’m building a theme, where I cannot enforce what people label their sections, this is a bit of an issue. Albeit probably not mainstream.

Offline

#4 2021-05-10 10:21:17

etc
Developer
Registered: 2010-11-11
Posts: 4,313
Website GitHub

Re: Pageless sections content can't be called via article_custom?

I’m sure there is a way. Could you try <txp:article_custom searchall />?

Offline

#5 2021-05-10 10:33:59

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

Re: Pageless sections content can't be called via article_custom?

etc wrote #330086:

I’m sure there is a way. Could you try <txp:article_custom searchall />?

Ah ha! That works (Textpattern 4.8.5). Has that attribute changed behaviour recently? It’s not listed on the article_custom tag doc but is mentioned on article tag doc…

searchall="boolean"
When outputting search results, include only those articles with ‘Include in site search’ set on the Sections panel. If set to 0, only articles in the current section are displayed.
Values: 0 (no) or 1 (yes).
Default: 1.

Offline

#6 2021-05-10 10:37:49

etc
Developer
Registered: 2010-11-11
Posts: 4,313
Website GitHub

Re: Pageless sections content can't be called via article_custom?

philwareham wrote #330087:

Ah ha! That works (Textpattern 4.8.5). Has that attribute changed behaviour recently – it’s not listed on the article_custom tag doc but is mentioned on article tag…

It has been extended to non-search situations when pageless sections were introduced, to include the latter. Works as before when in search.

Offline

#7 2021-05-10 10:39:53

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

Re: Pageless sections content can't be called via article_custom?

etc wrote #330088:

It has been extended to non-search situations when pageless sections were introduced, to include the latter.

OK thanks Oleg, great stuff. I think we need to update the docs to reflect this on both article and article_custom tag doc pages.

Offline

Board footer

Powered by FluxBB