Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Nesting Tags Without Resorting to PHP?
In a bid to nest tags I stumbled across this workaround:
<code><txp:article_custom form=“events” section=“events” category=”<txp:category /></code>
By using the nested tag as the closing bracket and removing one of the quotation marks it seems to work?! Or is this a standard workaround?Last edited by Sencer (2006-09-02 22:11:37)
Offline
Re: Nesting Tags Without Resorting to PHP?
Do not do this. It didn’t work for me (even though it didn’t throw an error). And even if it did work, it would be by pure coincidence and behaviour could change any time.
If you do not want to use PHP in templates, the correct way is to write a small wrapper tag/function in a plugin, and call that in your template.
Offline
Re: Nesting Tags Without Resorting to PHP?
Hi Sencer – Yep I thought it was a bit of an illegal workaround. I had the code in a form rather than a page template…not sure if that makes any difference. Any idea what the the PHP equivalent would be?
Cheers.
Offline
Re: Nesting Tags Without Resorting to PHP?
toots wrote:
I had the code in a form rather than a page template…not sure if that makes any difference.
No, it usually doesn’t make a difference.
Any idea what the the PHP equivalent would be?
Please ask in the support-forums, or one of the existing threads. Thanks.
edit: OK, given that the convertion turned into a “How do I”, I have moved this topic.
Last edited by Sencer (2006-09-02 22:12:29)
Offline
Re: Nesting Tags Without Resorting to PHP?
Offline
Re: Nesting Tags Without Resorting to PHP?
Just the info i needed. Thanks.
Offline
Re: Nesting Tags Without Resorting to PHP?
Ok so reading your article I can understand why removing the extra closing bracket and quotation would work, albeit a highly risky workaround. Thanks.
Offline
#8 2006-09-02 19:18:04
- Ace of Dubs
- Member
- Registered: 2006-04-17
- Posts: 446
Re: Nesting Tags Without Resorting to PHP?
Great article wet.
Still I cant help but wish someone would make a plugin for this functionality.. there is something wonderfully elegant about the “naive” example you used.
Offline
Re: Nesting Tags Without Resorting to PHP?
I’m struggling a bit with the syntax here. Am I far off?
<code><txp:if_article_category number=“2” name=”<txp:category/>” >DO SOMETHING </txp:if_article_category> </code>
<code>
<txp:php>
$atts = array(
‘name’ => category(array())
);
$thing = ‘DO SOMETHING’;
echo if_article_category ($atts, $thing);
</txp:php>
</code>
Last edited by toots (2006-09-02 22:38:19)
Offline
#10 2006-09-02 23:35:54
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Nesting Tags Without Resorting to PHP?
If you don’t mind I’ll delete your second post about this. You were absolutely right in posting in this forum, but we’ll save you the trouble to keep up with two threads ;)
Offline
#11 2006-09-03 04:10:36
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Nesting Tags Without Resorting to PHP?
<txp:php>
$category = category(array());
if ($category)
{
$atts = array(
'number' => '2',
'name' => $category
);
$thing = 'DO SOMETHING';
echo if_article_category($atts, $thing);
}
</txp:php>
:)
Offline
Re: Nesting Tags Without Resorting to PHP?
Hi Els, yep no worries one thread is more than enough!
Mary: thanks a bunch. I can see I was a little off with my version :)
Offline