Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-12-30 13:57:50

geoff777
Plugin Author
From: Benarrabá Andalucía Spain
Registered: 2008-02-19
Posts: 282
Website

Quotation Marks ...

Hi,

I’ve been trying to write a link using adi_link.

<txp:adi_link url="<txp:site_url />" urlvars="direction=0&offset='<txp:variable name="offset" />'" />

Which doesn’t work because of the use of this quotation mark “offset

Is there a third style of quotation mark I can use to get around this?

Thanks
Geoff


There are 10 types of people in the world: those who understand binary, and those who don’t.

Offline

#2 2009-12-30 14:00:46

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,942
Website GitHub

Re: Quotation Marks ...

Does this work:

<txp:adi_link url="<txp:site_url />" urlvars='direction=0&offset=<txp:variable name="offset" />' />

?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2009-12-30 14:41:42

geoff777
Plugin Author
From: Benarrabá Andalucía Spain
Registered: 2008-02-19
Posts: 282
Website

Re: Quotation Marks ...

Works perfectly Stef – thank you.

I thought (wrongly) that if you had a second <txp:tag /> embedded in another <txp:tag /> it had to be wrapped in ‘…’ quotes.

Hence my original

<txp:adi_link url="<txp:site_url />" urlvars="direction=0&offset='<txp:variable name="offset" />'" />

Cheers Stef


There are 10 types of people in the world: those who understand binary, and those who don’t.

Offline

#4 2009-12-30 17:09:05

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,942
Website GitHub

Re: Quotation Marks ...

geoff777 wrote:

Works perfectly Stef – thank you.

Cool.

I thought (wrongly) that if you had a second <txp:tag /> embedded in another <txp:tag /> it had to be wrapped in ‘…’ quotes.

You thought rightly in the first place! You do indeed have to have single quotes round an embedded txp:tag if you want it to be parsed as a tag. The difference with the version I posted is that the single quotes are round the entire urlvars attribute. Thus everything inside it is parsed, and it alleviates the need for a third set of quotes which, as you found, makes things trickier. Depending on the rest of the content this might parse a few microns slower than trying to do what you did originally, but it’s negligible compared to retaining your sanity :-)

fwiw, this can also be used to good effect if you want more than one tag to be parsed in a single attribute, e.g.

<txp:adi_link url='<txp:site_url /><txp:section />' />

Check out Textbook on the subject if you want some more zany examples.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB