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!

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 06:28:39
Script start
Timing: Jan 31 2025 06:28:39
Module start 'layout'
Timing: Jan 31 2025 06:28:39
Module start 'content'
Timing: Jan 31 2025 06:28:39
Module end 'content'
Timing: Jan 31 2025 06:28:39
Script end

Main resources:

Total runtime0.0132 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0043 588.0000151.1953
Module start 'layout' 0.00430.0025 739.195336.6016
Module start 'content' 0.00680.0047 775.796990.0938
Module end 'content' 0.01150.0016 865.890633.9922
Script end 0.0132  899.8828 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002317.1659140.0002
Check MTime0.00118.1276140.0001
Mysql Total
Database connection0.00075.552410.0007
Mysqli_queries0.002216.996430.0007
Looping result0.00000.083010.0000
Template Total0.00118.310.0011
Template load0.00086.353110.0008
Template processing0.00031.944010.0003
Override
Cache load0.00064.174710.0006
General
dbfile0.00107.436980.0001
String conversion0.00000.055940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_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