Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-10-19 10:40:09

R.M.S.
Member
Registered: 2005-09-12
Posts: 15

tags -in- tags

What I’d like to do is the following:
<code><txp:article_custom id=”<txp:sch_edito editie=”<txp:sch_editie />” />” /></code>

Basically:
- sch_editie gives an edition number (I’m developping the site for a student paper).
- sch_edito gives the ID of the editorial of that edition.
- article_custom displays the editorial.

But tags in tags don’t seem to work, so is the only option left to just get the article out by means of a specific query instead of using the code here displayed?

Last edited by R.M.S. (2005-10-19 10:40:25)

Offline

#2 2005-10-19 15:51:52

R.M.S.
Member
Registered: 2005-09-12
Posts: 15

Re: tags -in- tags

Solution: adress the functions directly instead of using the TxP-tags for those functions.

<code>
<txp:article_custom id=”<?php echo sch_edito(sch_editie()); ?>” />
</code>

edit: Hmm, apparently not. Still searching :)

Last edited by R.M.S. (2005-10-19 16:01:06)

Offline

#3 2005-10-19 16:12:09

Elenita
Member
From: Falls Church, VA
Registered: 2004-05-16
Posts: 407
Website

Re: tags -in- tags

R.M.S., to ask the obvious: are you using a plugin or hack that has created the <code><txp:sch_editie /></code> tag within Textpattern? And, if so, have you turned it on?

Because while using tags within tags do work, the tag you’re using above isn’t included in Textpattern by default. As such, unless you’ve enabled it by a plugin, the code you’re using in your template isn’t recognized and thus ignored. On the other hand, if you are using a plugin, this question might be better asked in the appropriate thread of the plugin subforum.

Last edited by Elenita (2005-10-19 16:13:10)

Offline

#4 2005-10-19 16:32:28

R.M.S.
Member
Registered: 2005-09-12
Posts: 15

Re: tags -in- tags

It’s activated: when not inside another textpattern-tag, it works as it should. So my conclusion: tags within tags don’t work. The PHP-solution you see above should work but apparently the tag is parsed before the PHP-script.

It’s not really a question of plugins not working, it is rather about how to use variable data inside a plugin, which is a quite necessary functionality imo.

Thanks,

Last edited by R.M.S. (2005-10-19 16:32:41)

Offline

#5 2005-10-19 16:34:50

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

Re: tags -in- tags

Because while using tags within tags do work,

Yes and no.
You can nest tags: <code><a><b /></a></code>.

You can not start a tag in the middle of another tag: <code><a<b/> /></code>. It “breaks” the parser. (It’s also extremely un-xml)

Last edited by Sencer (2005-10-19 17:37:58)

Offline

#6 2005-10-19 16:51:07

R.M.S.
Member
Registered: 2005-09-12
Posts: 15

Re: tags -in- tags

I see what you mean, but terminology aside: how the hell do I get this working then? :-)

Those two functions need to provide a certain number for article_custom to use as an ID. So while the code as you see it might seem “un-xml”, the result would be something like <code><article custom id=“12” /></code>. That’s why I tried the php-solution, but for some reason or other that doesn’t work.

Last edited by R.M.S. (2005-10-19 16:51:43)

Offline

#7 2005-10-19 16:57:24

Elenita
Member
From: Falls Church, VA
Registered: 2004-05-16
Posts: 407
Website

Re: tags -in- tags

<blockquote>You can not start a tag in the middle of another tag: />. It “breaks” the parser. (It’s also extremely un-xml)</blockquote>

Ah, thanks, Spencer. That’s good to know.

Offline

#8 2005-10-19 17:31:59

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

Re: tags -in- tags

So if I wanted to display a list of all articles belonging to the current section, how would I achieve this? It would require a sequence like that:

bc..<ul>
<txp:article_custom form=“simplelist” section=”{txp:section /}” />
</ul>

which is not parseable. Any ideas?

(curly bracket used in order to satisfy this @%§ forum message parser)

Last edited by wet (2005-10-19 17:33:09)

Offline

#9 2005-10-19 17:53:51

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

Re: tags -in- tags

The shortest is to use PHP in your templates, the “cleaner” way is to write a plugin for that purpose.

Example:
<code>
<txp:php>echo article_custom(array(“form”=>“default”, “section”=> section(array())));</txp:php>
</code>

This calls the article_custom function with an associative array for the parameters, setting form and section. form is set to “default”, whereas “section” is set to the return value of the function call to section() (to which we have to pass at least an empty array as parameter).
A plugin would be just as short. I have a plugin dedicated to these kind of one-liners, where I just add stuff as I go along.

Of course you have to know php so this is not a solution for your average user.

Offline

#10 2005-10-19 18:08:58

R.M.S.
Member
Registered: 2005-09-12
Posts: 15

Re: tags -in- tags

Hmmm, interesting. Thanks.

Offline

#11 2005-10-19 18:51:00

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: tags -in- tags

<blockquote>So if I wanted to display a list of all articles belonging to the current section, how would I achieve this? It would require a sequence like that:
<code><ul>
<txp:article_custom form=“simplelist” section=”{txp:section /}” />
</ul></code></blockquote>

Why dont you use conditional if_section?
<code>
<txp:if_section name=“about”>
<ul>
<txp:article_custom form=“simplelist” section=“about” />
</ul>
</txp:if_section>
</code>

It can also be
<code>
<txp:if_section name=“about”>
<ul>
<txp:article form=“simplelist” />
</ul>
</txp:if_section>
</code>

I think there are also some plug-ins that can do that, as chh_article_custom or… your own <a href=“http://awasteofwords.com/article/djwsectionarticles-textpattern-plugin”>djw_section_articles</a> (Or am I wrong?)

wet:
can you create a forum thread to discuss your djw_section_articles plug-in ? I cant make it work.

Last edited by maniqui (2005-10-19 19:05:52)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#12 2005-10-19 19:23:19

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

Re: tags -in- tags

> maniqui wrote:

Why dont you use conditional if_section?

Because I’d prefer a generic solution which would not require hard-coded section names.

I think there are also some plug-ins that can do that, as chh_article_custom or… your own <a href=“http://awasteofwords.com/article/djwsectionarticles-textpattern-plugin”>djw_section_articles</a> (Or am I wrong?)

Thanks a lot for your suggestions, but sadly both are no solution to my requirements right now. Chh_article_custom would require to pass the current section as a tag-in-tag just like txp:article_custom does, which is impossible as this past discussion proved.

Djw_section_articles is very limited in the way it renders its list. I’d rather delegate the rendering of the listed articles into a user supplied form than control every bit of HTML via plugin attributes. You will notice that said plugin currently requires more than enough attributes to just render an unordered list.

I am currently doing a layout which would require an article listing with title and article_thumbnail (both with permlinks) and excerpt per article (kind of “related_articles with pics”). I could certainly squeeze all this into a plugin, but this would result in a loss of flexibilty and elegance. Forms are definitely preferable for layouting purposes. So article_custom is my choice of weapon, and Sencer’s PHP driver snippet is an enlightenment.

If only txp:article_custom had the possibility to pass section="%current" or the like, %current being defined as a special purpose keyword… I would turn this into a feature request, but I have not been very successful with FRs in the past.

//w&

Last edited by wet (2005-10-19 19:33:02)

Offline

Board footer

Powered by FluxBB