Author
|
Message
|
Gabriel Ambuehl
|
Wednesday 05 January 2005 8:28:40 am
This must be something trivial I'm overlooking. I got a Country class (just one field, name of the country) and a Photograph (identifier photograph) class containing various fields among them an object relation to Country (called "Country" and identified by "country"). Now I want the Country template to show photographs taken there:
{section name=Photograph loop=fetch( 'content', 'list', hash( attribute_filter, array('parent_node_id', 93, 'photograph/country', '=', $node.object.id ) ) ) }
<a href={$Photograph:item.main_node.url_alias|ezurl}>{$Photograph:item.name}</a>
{/section}
Edit: maybe this doesn't work at all. ezobjectrelation isn't listed as a attribute_filter enabled data type. So is there any other way to do this?
Visit http://triligon.org
|
Paul Borgermans
|
Wednesday 05 January 2005 9:47:08 am
Gabriel, You will have to use content/search instead of content/list. I do it quite often with the standard related object datatypes (with search restrictions). This strategy does not always work though (all searchable attributes of the related object are used), but it should work in your case. The search string should be simply the $node.name. We have a custom related object list datatype in use here --made by Hans Melis-- which has the reverse related objects listed, similar to the one posted by Xavier Dutoit. But it is not requiring an extra table. It actually uses the normal object relations to have the reverse list. Maybe Hans should put it in pubsvn too ;-) as it provides this type of functionality -paul
eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans
|
Gabriel Ambuehl
|
Wednesday 05 January 2005 10:18:10 am
Actually, it seems to work with:
{section name=Photograph loop=fetch( 'content', 'list', hash( attribute_filter, array('or', array('parent_node_id', 93, 'photograph/country', '=', $node.object.id ) ) )) }
<a href={$Photograph:item.url_alias|ezurl}>{$Photograph:item.name}</a>
{/section}
I.e. an array('or' [...]) wrapper around the parameters for attribute_filter. I suppose I'll have to use content/tree as it's not entirely clear that all photographs will be direct children of the same node. But I feel I tackled the worst parts. I will look into content/search though. Thanks for your advice.
Visit http://triligon.org
|
Gabriel Ambuehl
|
Thursday 06 January 2005 10:22:22 am
I was looking into content,search but it doesn't ever find anything. Can anyone confirm that it in fact does work on 3.5?
{section loop=fetch( content, search, hash( text, 'Spain') )}
<a href={$:item.main_node.url_alias|ezurl}>{$:item.name}</a><br />
{/section}
Visit http://triligon.org
|
Paul Borgermans
|
Thursday 06 January 2005 10:46:51 am
Hi Gabriel, The result of the search includes a search count, some other goodies like search words omitted and the searchresults as a sub-array. You should use it like the following:
{let mysearch=fetch( content, search, hash( text, 'Spain') )}
{*discover some more: uncomment the line below*}
{*$mysearch|attribute(show)*}
{*end discover *}
{section loop=$mysearch.SearchResult var=result}
<a href={$result.main_node.url_alias|ezurl}>{$result.name}</a><br />
{/section}
{/let}
Also notice the better use of <b>var=</b> instead of the swampy section name spaces. hth -paul
eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans
|
Gabriel Ambuehl
|
Friday 07 January 2005 12:30:58 am
Thanks, this works. Seems like the doc to the search operator is totally wrong. I'll file a bug report later on.
Visit http://triligon.org
|
Jan Borsodi
|
Friday 07 January 2005 1:31:16 am
The doc for the search operator is now updated. http://ez.no/ez_publish/documentation/reference/data_fetching/content/search Is the new text sufficient or should we add more details?
--
Amos
Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq
|
Gabriel Ambuehl
|
Friday 07 January 2005 2:05:57 am
I think the new docs are much better indeed.
Visit http://triligon.org
|
Xavier Dutoit
|
Thursday 13 January 2005 1:25:15 pm
Paul mentionned my modest contribution (found on the pubsvn or http://www.ez.no/community/contribs/datatypes/enhanced_objectrelation ) and I think it should do what you need. Just a small correction on Paul comments: you have to modify one existing table, not add a new one. I wanted to be able to have several attributes relatedobjects on one class I couldn't find a way to know for each related object if it was a plain related object or related because of an objectrelation attribute, and which one. X+
http://www.sydesy.com
|
Gabriel Ambuehl
|
Thursday 13 January 2005 2:05:06 pm
Xavier, I do in fact like your enhanced object relation very much but it's not really useful as the relations are doubled in 3.5 each edit (look at my postings on the page of the module). BTW, I have code on my HD to add metadata for searching (only default language so far, though, not sure if it's sensible to also add all translations to the index?). I'd love to share it, please advise where I should put it. I've also filed a bug related to the cloning: http://ez.no/bugs/view/6081
Visit http://triligon.org
|