Forums / General / php operators

php operators

Author Message

Marc Boon

Friday 03 March 2006 6:21:56 am

I try to implement a php operator, but without success. The only documentation I could find about it is a comment in template.ini

What I need is a string replace function, like the php function str_replace.
So I added this to /settings/override/template.ini.append.php:

[PHP]
PHPOperatorList[replace]=str_replace

I hoped that something like this would work to create a url to the current node in another siteaccess, for a multilingual site (any other suggestions also welcome!):

{$node.url|ezurl(no)|replace('/eng/','/deu/')}

but the result is the same as without the replace() operat or.

I also tried this:

{replace('/eng/','/deu/',$node.url|ezurl(no))}

but then the result is 'Array'.

Mads Ovesen

Friday 03 March 2006 6:32:38 am

You can only use php operators that take one parameter: See http://ez.no/products/ez_publish/documentation/development/kernel/custom_template_operators
under limitations.

Instead you'll have to check your language in site.ini an make the url using the concat function.

/m

Marc Boon

Friday 03 March 2006 7:36:52 am

Problem with hardcoded urls is that it isn't portable between different configurations.
I used the ezurl() operator to automatically add the index.php(?) if needed. My development site runs on a machine with mod_php, and the production server uses CGI, so they need different urls.

Marc Boon

Sunday 05 March 2006 1:57:39 am

Just found exactly what I needed in Contributions:
http://ez.no/community/contribs/template_plugins/string_replace_operator

Thank you Alexandre Abric!

eZ debug

Timing: Jan 19 2025 06:21:34
Script start
Timing: Jan 19 2025 06:21:34
Module start 'content'
Timing: Jan 19 2025 06:21:34
Module end 'content'
Timing: Jan 19 2025 06:21:34
Script end

Main resources:

Total runtime0.0921 sec
Peak memory usage2,048.0000 KB
Database Queries4

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0077 588.7734180.8594
Module start 'content' 0.00770.0143 769.632893.7969
Module end 'content' 0.02200.0699 863.429770.7031
Script end 0.0919  934.1328 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00283.0634120.0002
Check MTime0.00111.2437120.0001
Mysql Total
Database connection0.00111.220910.0011
Mysqli_queries0.00586.348140.0015
Looping result0.00000.020720.0000
Template Total0.069375.310.0693
Template load0.00090.969810.0009
Template processing0.068474.294010.0684
Override
Cache load0.00060.681010.0006
General
dbfile0.046450.4055100.0046
String conversion0.00000.005730.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs