Forums / Discussions / Understanding and developing fetch functions

Tuesday 14 September 2010 4:41:08 am - 8 replies

» Read full tutorial

Introduction

This tutorial will explain how template fetch functions work and how to develop custom ones. It will also show you how to call them from PHP.

 
Author Message

SEBBANE Alexandre

Wednesday 15 September 2010 6:43:03 am

Cool, you want the award this year or not ?

Paris, France

Romeo Antony

Wednesday 15 September 2010 11:15:34 am

So simple. It can easily understandable even for a newbie.

I appreciate your time and work for this great article.

I have a suggestion ,it would have been a better idea if you could include some cutom fetch example that make some sense

in the php method ,

<span>public</span> <a href="http://www.php.net/static" mce_href="http://www.php.net/static" target="ez_no_documentation"><span>static</span></a> <span>function</span> getMyFetchFunctionResult<span></span>

Romeo Antony

Oman , GCC

Jérôme Vieilledent

Wednesday 15 September 2010 12:10:05 pm

Hi Romeo

I don't really get your suggestion :/...

Could you be more explicit please ?

Romeo Antony

Wednesday 15 September 2010 1:21:27 pm

Thank you for the followup Jerome.

In function , you did like this

$result = array(
'first_key' => 'foo',
'second_key' => 'bar'
)

I know ,It is for simplicity. instead of that, if you show some meaningful custom fetch function operations with parameters could be really helpful .Since this article is fully focusing on extending custom fetch function .

Anyway I really enjoyed this article. This week beginning I have just started on try to develop simple extensions. This article is an additional help for my tries.

Anders Berre

Friday 17 September 2010 2:05:41 am

Nice tutorial, very good work!

I think this is one of my favorite functionallity with eZ Publish. Have made many custom fetches to make things easy! :-)

Sincerely,

Anders Sandvik Berre
http://www.netmaking.no/

André R.

Monday 20 September 2010 3:49:45 am

Nice article, however I don't see the need to have an catch all try block on the "How it works" page. 1. No fetch functions use exceptions, they use null/false normally to indicate issues. 2. pokemon exceptions handling ( "Gotta Catch 'Em All" ) ? :)

As in: basically only use try block if the api your using uses exceptions, and then stricten the match for those exceptions instead of unintentionally catching exceptions your not supposed to handle(that might show up in the future, lets say for mvc exceptions for instance).

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Jérôme Vieilledent

Thursday 23 September 2010 5:06:24 am

Hi everyone

Thanks for your nice feedback :)

André : Actually, I always use try/catch blocks as I always use exceptions in case of errors. This is just a (nice) habit ;-)

Joël LEGER

Monday 04 October 2010 1:49:42 am

Hi Jérôme,

Clear and neat tutorial ... perfect work.

Joël

You must be logged in to post messages in this topic!

eZ debug

Timing: Jan 17 2025 22:58:31
Script start
Timing: Jan 17 2025 22:58:31
Module start 'content'
Timing: Jan 17 2025 22:58:31
Module end 'content'
Timing: Jan 17 2025 22:58:31
Script end

Main resources:

Total runtime0.4105 sec
Peak memory usage4,096.0000 KB
Database Queries230

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0088 588.9609180.8125
Module start 'content' 0.00880.2159 769.7734915.2969
Module end 'content' 0.22460.1858 1,685.0703344.4609
Script end 0.4105  2,029.5313 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00461.1180210.0002
Check MTime0.00170.4125210.0001
Mysql Total
Database connection0.00120.299310.0012
Mysqli_queries0.288770.32922300.0013
Looping result0.00240.59152280.0000
Template Total0.372890.820.1864
Template load0.00210.503020.0010
Template processing0.370790.298420.1853
Template load and register function0.00020.049010.0002
states
state_id_array0.00180.442320.0009
state_identifier_array0.00160.378130.0005
Override
Cache load0.00180.4394520.0000
Sytem overhead
Fetch class attribute name0.00130.3066140.0001
Fetch class attribute can translate value0.00130.328670.0002
class_abstraction
Instantiating content class attribute0.00000.0076160.0000
XML
Image XML parsing0.00811.975070.0012
General
dbfile0.01403.4032530.0003
String conversion0.00000.002930.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
1node/view/full.tplforum_topic/full.tplextension/community_design/design/suncana/override/templates/forum_topic/full.tplEdit templateOverride template
9content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/separator.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltags/separator.tplEdit templateOverride template
7content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/emphasize.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/emphasize.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 33
 Number of unique templates used: 9

Time used to render debug report: 0.0002 secs