Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Registered PHP functions for the evaluate tag [Solved]
I’m sorry, but I forgot how to use a registered PHP number_format() function with a <txp:evaluate />
tag. Second: can we add multiple PHP functions (maybe within a comma separated list) ?
Last edited by Pat64 (2023-07-02 16:25:41)
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Re: Registered PHP functions for the evaluate tag [Solved]
You first need to switch on “Advanced Options” in the Admin Settings. Then reload the page and add the PHP functions you want to use to the field PHP functions enabled in txp:evaluate. You can add several functions separated by commas just as you suggest.
TXP Builders – finely-crafted code, design and txp
Online
Re: Registered PHP functions for the evaluate tag [Solved]
Thanks. Could you give me a sample with usage into a <txp:evaluate />
tag (based on the PHP number_format()
function)?
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Re: Registered PHP functions for the evaluate tag [Solved]
I’m sorry. I realised I misunderstood your question (I did think you’d be familiar with what I wrote).
To answer your question, like this:
<txp:variable name="myval">123453465</txp:variable>
<txp:evaluate query='number_format(<txp:variable name="myval" />, 2, ",", " ")' />
<!-- returns "123 453 465,00" -->
<txp:variable name="decval">12345.3465</txp:variable>
<txp:evaluate query='number_format(<txp:variable name="decval" />, 2, ",", " ")' />
<!-- returns "12 345,35" -->
Now I also know what you mean with the comma separated php functions. I’m not sure about that.
TXP Builders – finely-crafted code, design and txp
Online
Re: Registered PHP functions for the evaluate tag [Solved]
Perfect !
And I found where I had a problem.
I tried (before asking some help) this:
<txp:evaluate query='number_format(custom_field(array('name'=>'pageviews')), 0, '', ' ')' />
First, the problem was caused by the use of quotation marks…
Second, I registered the PHP function as… a function like this number_format()
For all: do not add any brackets with the registered PHP functions.
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline