eZ Community » Forums » Developer » Difference between content and...
expandshrink

Difference between content and contentfetch inside fetch function

Difference between content and contentfetch inside fetch function

Monday 27 April 2015 8:06:04 am - 3 replies

Hi,

What's the difference between 2 versions of fetch functions stated below:

 fetch(content, tree, hash())
fetch(contentfetch, tree, hash())

Thanks

Modified on Monday 27 April 2015 8:14:28 am by Rashidul Islam Rana

Monday 27 April 2015 9:38:56 am

Hello Rashidul,

The differences are subtle but specific. In short the difference is the depth parameter's default value.

With content, tree the depth is unlimited (meaning all possible results).

While with content, list the depth is 1 (meaning one level of content tree results).

 

Besides this aspect the content list and tree functions are nearly identical and even are powered by the same underlying php function:

https://github.com/ezsystems/ezpublish-legacy/blob/master/kernel/content/function_definition.php#L338

https://github.com/ezsystems/ezpublish-legacy/blob/master/kernel/content/function_definition.php#L198

 

The documentation is helpful in understanding this aspect:

https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Modules/content/Fetch-functions/tree

https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Modules/content/Fetch-functions/list

Please note that the content, tree does not in fact return results in a tree, per say, instead it returns results in the normal array of ezcontentobjecttreenode(s).

I hope this helps!

Cheers,
Heath

Monday 27 April 2015 10:16:24 am

Howdy Heath,

 

Thank you for your response.

However I was actually looking forward to know the difference between "content" and "contentfetch" [First Parameter] instead of list,tree. In my query, both second param is tree.

 

Thanks

Monday 27 April 2015 10:39:12 am

Hello Rashidul,

Apologies, I thought that your mention of 'contentfetch' was a typo and you actually meant, 'content'.

In short, there is no 'contentfetch' by default.

See, the first parameter to a fetch function is the module identifier, ie: content => content module fetch function. This first parameter provides for custom module's to provide custom / unique fetch functions.

If you see 'contentfetch' in your template code you are either seeing a typo / bug OR a custom module's custom fetch function (which is entirely possible).

That said if you are seeing a working use of 'contentfetch' then you can perform a code review and find the custom module's custom fetch function and document it yourself locally as we can not help review code we have never seen before.

Also I have never seen a publicly shared custom module named 'contentfetch' before.

I hope this helps!

Cheers,
Heath

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from