eZ Community » Forums » Discussions » Understanding and developing fetch...
expandshrink

Tuesday 14 September 2010 1:41:08 pm - 15 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.

 

Wednesday 15 September 2010 3:43:03 pm

Cool, you want the award this year or not ?

Wednesday 15 September 2010 8:15:34 pm

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

Modified on Wednesday 15 September 2010 10:23:41 pm by Romeo Antony

Wednesday 15 September 2010 9:10:05 pm

Hi Romeo

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

Could you be more explicit please ?

Modified on Wednesday 15 September 2010 9:11:51 pm by Jérôme Vieilledent

Wednesday 15 September 2010 10: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.

Modified on Wednesday 15 September 2010 10:22:47 pm by Romeo Antony

Friday 17 September 2010 11: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! happy.gif Emoticon

Monday 20 September 2010 12:49:45 pm

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" ) ? happy.gif Emoticon

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).

Modified on Monday 20 September 2010 12:50:40 pm by André R

Thursday 23 September 2010 2:06:24 pm

Hi everyone

Thanks for your nice feedback happy.gif Emoticon

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

Monday 04 October 2010 10:49:42 am

Hi Jérôme,

Clear and neat tutorial ... perfect work.

Joël

Tuesday 10 April 2012 6:18:18 pm

Hi,

I'm trying to do a fetch extension in  Comunauty release 2012.2.

I thing i make a lot of mistakes because it doesn't work. My extension is active but when i trace

ExtensionRepositories of module.ini there is not my repository.

Is now organisation between files different ? files path too ?

 

 

Wednesday 11 April 2012 9:56:05 am

I will complete my question.

When i trace what eZ is doing i saw that it's looking in folders but not mine :

Error: eZModuleFunctionInfo::loadDefinition Apr 11 2012 09:30:38
Path :kernel/depeches/function_definition.php
Error: eZModuleFunctionInfo::loadDefinition Apr 11 2012 09:30:38
Path :kernel/private/modules/depeches/function_definition.php
Error: eZModuleFunctionInfo::loadDefinition Apr 11 2012 09:30:38
Path :extension/ezjscore/modules/depeches/function_definition.php
Error: eZModuleFunctionInfo::loadDefinition Apr 11 2012 09:30:38
Path :extension/ezodf/modules/depeches/function_definition.php
Error: eZModuleFunctionInfo::loadDefinition Apr 11 2012 09:30:38
Path :extension/ezscriptmonitor/modules/depeches/function_definition.php
Error: eZModuleFunctionInfo::loadDefinition Apr 11 2012 09:30:38
Path :extension/ezmultiupload/modules/depeches/function_definition.php
Error: eZModuleFunctionInfo::loadDefinition Apr 11 2012 09:30:38
Path :extension/ezoe/modules/depeches/function_definition.php
Error: eZModuleFunctionInfo::loadDefinition Apr 11 2012 09:30:38
Path :extension/ezie/modules/depeches/function_definition.php
Error: eZModuleFunctionInfo::loadDefinition Apr 11 2012 09:30:38
Path :extension/ezcomments/modules/depeches/function_definition.php
Error: eZModuleFunctionInfo::loadDefinition Apr 11 2012 09:30:38
Path :extension/ezfind/modules/depeches/function_definition.php
Error: eZModuleFunctionInfo::loadDefinition Apr 11 2012 09:30:38
Path :extension/eztags/modules/depeches/function_definition.php

(Message are stranges because i made a "hack" in ezmodule.php to trace what it did )

 

And at the end :

Error: eZModuleFunctionInfo::loadDefinition Apr 11 2012 09:30:38
No file Missing function definition file for module: depeches

My file tree is :

ezidlfetch

        classes

               depechesfunctioncollection.php

        modules

               depeches

                     function_definition.php

                     module.php

        settings

               design.ini.append.php

               module.ini.append.php

               site.ini.append.php

 

In each files i wrote same things of your examples.

 

I precise that when i do a ./bin/php/ezpgenerateautoloads.php -e -v

I have : 'depechesFunctionCollection'          => 'extension/ezidlfetch/classes/depechesfunctioncollection.php',

 

Wednesday 11 April 2012 12:13:24 pm

Hi Grégory

What do you have in your module.ini.append.php ?

Wednesday 11 April 2012 3:29:32 pm

Thank you for your reply.

In fact i had no \r and \n in my module.ini.append.php.
It was THE big problem of my problem. I play with eZINI classe make a lot of trace and i understand that it will be a character mistake.

Eclipse is not a good friend for this kind of stuff, but vi save me.

So now it works, i will try to do my fetch function to connect with external DB.

I think it will be good to precise in documentation that \n et \r are used to do parsing in eZINI. They talk about white space but no focus about \n \r.

Last question, why there is no use of trim() in parseFile() methos of eZINI ? performance ? trim is evil ?

Wednesday 11 April 2012 3:37:10 pm

Quote from MONOT Gregory :

Last question, why there is no use of trim() in parseFile() methos of eZINI ? performance ? trim is evil ?

I don't really know honestly...

Wednesday 01 August 2012 9:41:18 am

hi..

actually iam new to ezpublish.... please help me ..actually i want to include some rotating images in my home page ....can u please guide me...

Monday 17 September 2012 3:15:30 pm

The reply has been removed because of violation of forum rules.

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from