Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-09-02 12:11:03

toots
Member
From: UK
Registered: 2005-05-19
Posts: 12
Website

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

#2 2006-09-02 12:40:59

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

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

#3 2006-09-02 12:57:28

toots
Member
From: UK
Registered: 2005-05-19
Posts: 12
Website

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

#4 2006-09-02 13:00:48

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

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

#5 2006-09-02 17:15:58

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,323
Website Mastodon

Re: Nesting Tags Without Resorting to PHP?

Offline

#6 2006-09-02 17:23:42

toots
Member
From: UK
Registered: 2005-05-19
Posts: 12
Website

Re: Nesting Tags Without Resorting to PHP?

Just the info i needed. Thanks.

Offline

#7 2006-09-02 17:35:54

toots
Member
From: UK
Registered: 2005-05-19
Posts: 12
Website

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

#9 2006-09-02 21:18:20

toots
Member
From: UK
Registered: 2005-05-19
Posts: 12
Website

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

#12 2006-09-03 08:24:59

toots
Member
From: UK
Registered: 2005-05-19
Posts: 12
Website

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

Board footer

Powered by FluxBB