Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2006-09-03 09:08:17

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

Re: Nesting Tags Without Resorting to PHP?

Damn it’s still coming up with a blank page. This is what i’ve got.

This works:
<code>
<txp:if_article_category name=“artist-01”>

<table cellpadding=“0”>
<tr> <th scope=“col”>Artist</th> <th scope=“col”>Date</th> <th scope=“col”>Event</th> <th scope=“col”>Venue</th> <th scope=“col”>City</th> </tr>
<txp:article_custom form=“events” section=“events” category=“artist-01”/>
</table>

</txp:if_article_category>
</code>

The PHP equivalent which doesn’t?
<code>
<txp:php>
$category = category(array());

if ($category)
{ $atts = array( ‘number’ => ‘2’, ‘name’ => $category );

$thing = ‘<table cellpadding=“0”>
<tr> <th scope=“col”>Artist</th> <th scope=“col”>Date</th> <th scope=“col”>Event</th> <th scope=“col”>Venue</th> <th scope=“col”>City</th> </tr>
<txp:article_custom form=“events” section=“events” category=“artist-01”/>
</table>’;

echo if_article_category($atts, $thing);
}
</txp:php>
</code>

All code is contained in a misc form and being outputted via page template with <code><txp:output_form form=“events_main” /></code>

Last edited by toots (2006-09-03 12:14:46)

Offline

#14 2006-09-03 11:58:16

Ace of Dubs
Member
Registered: 2006-04-17
Posts: 446

Re: Nesting Tags Without Resorting to PHP?

I feel your pain, toots. I tried to do something similar, using one of Mary’s code examples no less.. but never got it working. I dont know enough PHP to say for sure, but I imagine something like this would be not be feasible as a plugin, otherwise it would probably already exist. You’re certainly not the first TXPer to face this limitation.

Offline

#15 2006-09-03 18:12:22

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

Re: Nesting Tags Without Resorting to PHP?

Yep it’s definitely making my head hurt! A plugin for this would be oh soooo sweet……..

Offline

#16 2006-09-03 19:05:41

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

Re: Nesting Tags Without Resorting to PHP?

Your code is explicitly specifying category 2 (number="2"), while your example <txp:if_article_category name="artist-01"> checks for any/both category fields. Is this a deliberate decision?

Offline

#17 2006-09-03 19:22:13

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

Re: Nesting Tags Without Resorting to PHP?

Hi Wet,

Yep that’s my mistake I left it out in that example. Still doesn’t work either way. I have categories from artist-01 through to artist-10. I want the form to dynamically pick up the correct article and spit out the corresponding data. At the moment I’m stuck handcoding them.

I actually couldn’t get the txp version to work with <code><txp:output_form form=“events_main” /></code>, however it does work when I change it to <code><txp: article/></code>.

Offline

#18 2006-09-04 03:50:53

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Nesting Tags Without Resorting to PHP?

I actually couldn’t get the txp version to work with <txp:output_form form="events_main" />

Of course: you were trying to use article form tags in a page.

…however it does work when I change it to <txp:article/>.

I don’t recommend this strategy, of article tags calling article tags.

The code you’ve posted doesn’t make clear what you’re trying to achieve. Could you please back up, and describe what you’re trying to do. I get the feeling you might be overcomplicating something somewhere.

Offline

#19 2006-09-04 04:03:42

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: Nesting Tags Without Resorting to PHP?

I dont know enough PHP to say for sure, but I imagine something like this would be not be feasible as a plugin, otherwise it would probably already exist.

More likely reason: there’s a better or simpler way of organising your content and structure to achieve a similar goal.


Alex

Offline

#20 2006-09-04 11:48:48

Ace of Dubs
Member
Registered: 2006-04-17
Posts: 446

Re: Nesting Tags Without Resorting to PHP?

I hear you, zem… In the past I have worked around the problem by re-structuring content or using other plugins but the solution was more of a pain to implement and maintain than simply nesting the desired tag. I think the fact that people are digging into PHP to get this working says a lot about the desire for such functionality.

While I have your attention I can ask directly: Would this be possible to implement as a plugin?

Offline

#21 2006-09-04 19:05:18

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

Re: Nesting Tags Without Resorting to PHP?

Ok I’m developing a music site which has sections discogrophy/music events/releases among others.
The client will input data for each artist category (artist-01, artist-02 etc) via custom fields.

eg. A section like discogrophy will show tabular data grouped by artist using a form like below:
<code>
<txp:if_article_category name=“artist-01”>

<table cellpadding=“0”>
<tr>
<th scope=“col”>Artist</th> <th scope=“col”>Date</th> <th scope=“col”>Event</th> <th scope=“col”>Venue</th> <th scope=“col”>City</th> </tr>
<txp:article_custom form=“events” section=“events” category=“artist-01”/>
</table>

</txp:if_article_category>
</code>
Basically i don’t want to repeat the exact same code for artist-02, artist-03 etc etc. Hence I wanted to do the following

<code><txp:if_article_category name=”<txp:category/>”.</code>

Hopefully that makes some kind of sense. :)

Last edited by toots (2006-09-04 19:06:01)

Offline

#22 2006-09-05 06:01:42

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,012
Website GitHub Mastodon Twitter

Re: Nesting Tags Without Resorting to PHP?

Sounds like the if_different tag might do what you are looking for


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#23 2006-09-06 05:41:50

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

Re: Nesting Tags Without Resorting to PHP?

Hi Colak,

Thanks i’ll check it out. Although I’m with ace on this one…a plugin for this type of functionality would be sweet.

Offline

Board footer

Powered by FluxBB