Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Tag in tag in tag possible?
Hi all
I ask here because i am not sure about the response!
I tried this code :
<txp:variable name="issub" value='<txp:category_lis parent='<txp:category />' exclude='<txp:category />' break="" />' />
It return nothing, I think the problem is making tag in tag in tag construction.
Then is this construction impossible to handle in txp? or is there a way?
Thanks
NB: If you ask what’s the purpose of the code, it try to know if a category has a subcategory or not.
Cheers
Offline
#2 2010-10-19 11:04:23
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: Tag in tag in tag possible?
1) Typo. “txp:category_lis” instead of “categoty_list”
2) quotes are nested wrongly. Should be:
<txp:variable name="issub" value='<txp:category_lis parent="<txp:category />" exclude="<txp:category />" break="" />' />
Last edited by redbot (2010-10-19 11:05:02)
Offline
Re: Tag in tag in tag possible?
Thanks redbot, but still not working
when i use:
<txp:variable name="issub" value='<txp:category_list parent="contact" exclude="contact" break="" />' />
where contact is a category, i got something, but using <txp:category /> not giving à response!
putting the site on debugging mode gives an error message:
Tag error: <txp:category_list parent="<txp:category />" exclude="<txp:category />" break="" /> -> Notice: Undefined variable: rs on line 1016
I also tested
<txp:category_list parent="'<txp:category />'" exclude="'<txp:category />'" break="" />
but same error
Offline
Re: Tag in tag in tag possible?
Yeeees I got it
The solution is a double single quote:
<txp:category_list parent=''<txp:category />'' exclude=''<txp:category />'' break="" />
Offline
Re: Tag in tag in tag possible?
redbot wrote:
2) quotes are nested wrongly.
Not exactly. That code does make it valid and parser will parse it, but the inner values are now literal and not parsed at all. Instead, you should use two pairs of single quotes to escape the inner quotes. Same goes for nested double quotes.
For example:
<txp:variable name="issub" value='<txp:category_list parent=''<txp:category />'' exclude=''<txp:category />'' break="" />' />
''
('
x 2) is escaped'
(single quote).""
("
x 2) is escaped"
(double quote).- So, you basically use the quote to escape the quote.
This does work to unlimited level of depth. For example this is valid too:
<txp:variable name="this" value="hi" />
<txp:variable name="hi" value='<txp:variable name="1" value=''<txp:variable name="2" value=''''<txp:variable name="this" />'''' /><txp:variable name="2" />'' /><txp:variable name="1" />' />
<txp:variable name="hi" />
It’s actually pretty cool that the current parser supports proper escaping that works to any extent. See more in Parsing Tag Attributes.
Tho, because we are talking about variable
s, you could also use variable’s container format. For example:
<txp:variable name="issub"><txp:category_list parent='<txp:category />' exclude='<txp:category />' break="" /></txp:variable>
Edit. Sometimes I’m too slow ninja.
Last edited by Gocom (2010-10-19 11:57:11)
Offline
#6 2010-10-19 12:15:22
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: Tag in tag in tag possible?
Gocom wrote:
Not exactly…
Yes you are perfectly right, after years I still regularly confuse txp and php quotes
Offline
Re: Tag in tag in tag possible?
Thanks both for you help
Know i have another problem using txp:if_variable that cant test where à variable is empty
a code :
<txp:if_variable name="issub" value="">
is always false even if issub is emty!!
I will use smd_if to handle that!
Syntax error and logic error!
I think i need to make a break !
Last edited by Dragondz (2010-10-19 12:28:43)
Offline
Pages: 1