Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Check if article exists, provide fallback content if not
For some of my theme modules, I’d like to check whether an article exists, and provide fallback content if not.
So, for example, check if an article in section pageless-content
with category homepage-heading
exists. If so, display that. If not, display some hard-coded text.
Is this possible? Thanks!
Offline
Re: Check if article exists, provide fallback content if not
Hi Phil,
this could work:
<txp:article_custom ...>
display that
<txp:else />
hard-coded text
</txp:article_custom>
Offline
Re: Check if article exists, provide fallback content if not
Actually, I might have found the answer in another thread?…
<txp:evaluate test="article_custom">
<txp:article_custom form="-module--text--heading01" section="pageless-content" category="homepage-heading" />
<txp:else />
<txt:output_form form="-module--text--heading01">
<txp:yield name="title" default="Placeholder title" />
<txp:yield name="excerpt" default="Placeholder excerpt" />
</txp:output_form>
</txp:evaluate>
Plus some conditional code in my -module--text--heading01
form to check/get the fallback yields.
Offline
Re: Check if article exists, provide fallback content if not
etc wrote #326682:
this could work …
Oh, I didn’t know you could put a <txp:else />
within a <txp:article_custom>
tag. Let me think about that. Cheers.
Offline
Offline
Re: Check if article exists, provide fallback content if not
Can I load yield contents into a <txp:article_custom>
tag’s section
, category
and id
attributes, when said article_custom tag is within an output_form? Can’t seem to get it to work.
Offline
Re: Check if article exists, provide fallback content if not
philwareham wrote #326686:
Can I load yield contents into a
<txp:article_custom>
tag’ssection
,category
andid
attributes, when said article_custom tag is within an output_form? Can’t seem to get it to work.
I can’t see why it would not work, need to see the forms code.
Offline
Re: Check if article exists, provide fallback content if not
Ignore my last post. I got it working now thanks.
Offline