Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
evaluate and XPATH string-length
Code
<txp:variable name="page_date"><txp:page_url type="month" /></txp:variable>
[<txp:variable name="page_date" />]-
[<txp:evaluate query='string-length( <txp:variable name="page_date" /> )' />]
Output
[2016]- [4]
[2016-06]- [4]
[2016-06-14]- [4]
I wasn’t expecting 4 every time. Is there anything obvious I am doing wrong?
Edit: I’ve made some progress. The variable isn’t actually getting passed to the XPath function – instead it is seeing “1996” every time.
Offline
Re: evaluate and XPATH string-length
Does it make a difference if you enclose the <txp:variable name="page_date" />
inside the string-length function with quotes (single or double – but you’ll need the two-singles trick if you choose the former) to indicate it’s a string?
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
Re: evaluate and XPATH string-length
Bloke wrote #324216:
Does it make a difference if you enclose the
<txp:variable name="page_date" />
inside the string-length function with quotes (single or double – but you’ll need the two-singles trick if you choose the former) to indicate it’s a string?
I literally just figured it out.
[<txp:evaluate query=' string-length( "<txp:variable name=''page_date'' />" )' />]
Offline
Pages: 1