Forums / General / Test an url before display them

Test an url before display them

Author Message

Sébastien Antoniotti

Friday 01 December 2006 6:45:37 am

Hi,

In a template I build on the fly links for htm pages like this :

{def $url_archive=concat("http://www.site.com/infos/", $temp_year,"/",$moisarchive,"_", $temp_year, "/",$view_parameters.day, "_",$moisarchive,".htm"))}
	
	<a href="{$url_archive}" target="_blank">{$url_archive}</a>

and I have this output : http://www.site.com/infos/2006/novembre_2006/12_novembre.htm

But I want to test if this url is correct, before display it, because it's possible that the .htm document doesn't exist, so I must test it like than a test with the "file_exist" fonction of php... but I haven't found the good template operator =(

eZ Publish Freelance
web : http://www.webaxis.fr

Nabil Alimi

Tuesday 05 December 2006 2:21:19 pm

Hi Sébastien,

Whenever you need a php method, you may add it to the template.ini file :

[PHP]
# A list with php functions and their equivelant template operator names
# Giving the operators a different name from the PHP functions
# are recommended, that way you ensure that all operators follow
# the same naming guidelines. It also means that you can change the
# php function later on without doing template changes.
PHPOperatorList[]
PHPOperatorList[urlencode]=urlencode

However this only works with operators that handles one parameter max.

My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr

Sébastien Antoniotti

Tuesday 05 December 2006 10:06:36 pm

Hi Nabil,

Thanks a lot for this feature !!!

I think that I can resolve my problem with it,

Thanks again,
Seb.

eZ Publish Freelance
web : http://www.webaxis.fr

kracker (the)

Wednesday 06 December 2006 12:08:05 am

While Nabil is correct about the use of eZ publish's built in PHPOperatorList feature.
<i>http://ez.no/ezpublish/documentation/development/kernel/custom_template_operators
http://ez.no/ezpublish/documentation/development/extensions/template_operator
http://ez.no/doc/ez_publish/technical_manual/3_8/reference/template_operators</i>

I find that feature horribly limited as it <i>only</i> works with PHP functions which accept <b>only one argument</b>, this greatly limits the PHP functions you can use.

I encourage you to use the wrapper operator contribution instead!
<i>http://ez.no/community/contribs/template_plugins/wrapper_operator</i>

The wrapper operator allows for use of any PHP function regardless of number of arguments or parameters.

Cheers,
<i>//kracker</i>

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

Sébastien Antoniotti

Wednesday 06 December 2006 6:59:03 am

You are right, this solution is better an more usefull !!

Thanks a lot ;)

eZ Publish Freelance
web : http://www.webaxis.fr

eZ debug

Timing: Jan 31 2025 08:10:43
Script start
Timing: Jan 31 2025 08:10:43
Module start 'content'
Timing: Jan 31 2025 08:10:43
Module end 'content'
Timing: Jan 31 2025 08:10:44
Script end

Main resources:

Total runtime0.3578 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0123 587.9219180.8438
Module start 'content' 0.01240.0104 768.765697.9609
Module end 'content' 0.02270.3350 866.7266526.5234
Script end 0.3578  1,393.2500 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00371.0381200.0002
Check MTime0.00140.3941200.0001
Mysql Total
Database connection0.00100.267210.0010
Mysqli_queries0.272476.13211410.0019
Looping result0.00140.38631390.0000
Template Total0.334593.510.3345
Template load0.00100.267410.0010
Template processing0.333593.194810.3335
Override
Cache load0.00060.174410.0006
Sytem overhead
Fetch class attribute can translate value0.00090.241110.0009
XML
Image XML parsing0.00020.069410.0002
General
dbfile0.03048.4890200.0015
String conversion0.00000.006930.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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.0002 secs