Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2010-07-05 20:33:31
- parlour
- Member
- From: Germany
- Registered: 2006-09-01
- Posts: 20
Don’t Display Articles If article_custom’s id Attribute Is Empty
tl;dr version (more background below): I would like the <txp:article_custom />
tag to only output an article if the id attribute has some value. If it is empy (like so: <txp:article_custom id="" />
) I would like it to output nothing. As is it will just output a list of all articles.
—
The promised background information: I have this problem because I’m using the awesome Multi-Lingual Publishing Pack plugin (MLP for short). It’s not a problem with the plugin, though – that is working as expected – rather one with the article_custom tag, so bear with me.
That’s how my code looks:
<txp:article_custom id='<txp:l10n_get_rendition_id articleid="1" />' />
All you have to know about this <txp:l10n_get_rendition_id />
tag is that with the MLP you have these bundles (called “Articles” in MLP lingo) which contain all the different translations (called “Renditions” in MLP lingo). Each of those bundles has their own id. The individual articles in these bundles also have their own ids. You give this <txp:l10n_get_rendition_id articleid="1" />
tag the id of the bundle (in this case “1”) and it will output the id of the article in the language that is at the moment displayed.
What’s important is this: If some bundle doesn’t have a, say, German version the <txp:l10n_get_rendition_id />
tag will just output nothing if someone is viewing the German localization. And then you end up with this:
<txp:article_custom id='' />
That’s the reason why I have this problem. Sure, I could make sure that I always have all translations ready, but I would like to have a bit more gracious error handling.
Offline
Re: Don’t Display Articles If article_custom’s id Attribute Is Empty
hi Michael:
This should work:
<txp:variable name="has_rendition" value='<txp:l10n_get_rendition_id articleid="1" />' />
<txp:if_variable name="has_rendition" value="">
<txp:else />
<txp:article_custom id='<txp:l10n_get_rendition_id articleid="1" />' />
</txp:if_variable>
Offline
#3 2010-07-05 20:54:31
- parlour
- Member
- From: Germany
- Registered: 2006-09-01
- Posts: 20
Re: Don’t Display Articles If article_custom’s id Attribute Is Empty
maniqui wrote:
This should work
It does, as a matter of fact. Awesome! Thanks!
Offline
#4 2010-07-06 02:51:06
- garycleft
- New Member
- Registered: 2010-07-06
- Posts: 1
Re: Don’t Display Articles If article_custom’s id Attribute Is Empty
I just wanted to say thanks for sharing this. Been trying to figure it out myself
Offline