Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-02-05 10:37:48

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,137
GitHub

[solved] A question of punctuation: tag nesting

I’m nesting tags three-deep, and I think I’ve got a tag attribute included incorrectly. I set a variable in my page, thus:

<txp:variable name="url_lemon" value="http://example.com" />

My section lemon is an article list, and in the article form I have this logic:

  • if the article custom field url is set, use that as the hyperlink target
  • if the article custom field url is not set, use the url_lemon as the hyperlink target

My code:

<a href='
    <txp:if_custom_field name="url">
        <txp:custom_field name="url" />
        <txp:else />
            <txp:variable name="url_<txp:section title=''1'' />" />
    </txp:if_custom_field>'>[...]</a>

If I substitute the variable chunk for # (i.e., something without delimiters), it works; but the code above doesn’t retrieve the variable. The problem, I think lays with the punctuation I’m using with the delimiter, and the '' being interpreted as a " – either that or I’m trying to nest too deeply. I’d be grateful for an extra pair of eyes on this, if anyone has any ideas. Thanks in advance.

Last edited by gaekwad (2014-02-05 14:32:48)

Offline

#2 2014-02-05 10:53:33

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: [solved] A question of punctuation: tag nesting

Double quotes are ok in HTML tags (even nested like <a href="<txp:tag attr="hi" />">...</a>), but not in txp tags:

<txp:variable name="url_<txp:section title=''1'' />" />

looks for a variable literally named url_<txp:section title=’‘1’‘ />. This should work (untested):

<a href="
    <txp:if_custom_field name="url">
        <txp:custom_field name="url" />
        <txp:else />
            <txp:variable name='url_<txp:section title="1" />' />
    </txp:if_custom_field>">[...]</a>

Offline

#3 2014-02-05 11:33:54

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,137
GitHub

Re: [solved] A question of punctuation: tag nesting

Thank you, Oleg – I appreciate your time and attention.

I’ll send the envelope of used € notes to the usual place.

Offline

#4 2014-02-05 14:31:30

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: [solved] A question of punctuation: tag nesting

gaekwad wrote #278675:

I’ll send the envelope of used € notes to the usual place.

Ecology-minded people are always a pleasure to help! While we are at tags parsing, it’s useful to know that txp sees and transforms nothing but <txp:tags />. Everything outside them (including quotes, matched or not) is just meaningless text.

Offline

#5 2014-02-05 14:33:28

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,137
GitHub

Re: [solved] A question of punctuation: tag nesting

etc wrote #278677:

[…] is just meaningless text.

Oh! You have read my blog, then.

Offline

Board footer

Powered by FluxBB