Wednesday 07 December 2005 6:54:09 am
Hi, to answer myself:
An extended attribute filter does the trick.
Info about them: http://ez.no/doc/ez_publish/technical_manual/3_6/reference/modules/content/fetch_functions/list settings/override/extendedattributefilter.ini.append.php
<?php /* #?ini charset="iso-8859-1"?
# eZ publish extended attribute filter configuration file.
#The name of the filter.
[ExtendedImageFilter]
#The name of the extension where the filtering code is defined.
ExtensionName=gwfutils
#The name of the filter class.
ClassName=eZExtendedImageFilter
#The name of the method which is called to generate the SQL parts.
MethodName=createSqlParts
#The file which should be included (extension/myextension will automatically be prepended).
FileName=kernel/classes/ezimagefilter.php
*/ ?>
and the filter class: ezimagefilter.php
<?php
class eZExtendedImageFilter
{
/*!
Constructor
*/
function eZExtendedImageFilter()
{
// Empty...
}
function createSqlParts( $params )
{
$result = array( 'tables' => '', 'joins' => '' );
if ( isset( $params['attribute'] ) )
{
$filterAttributeID = $params['attribute'];
}
else
return $result;
if ( !is_numeric( $filterAttributeID ) )
$filterAttributeID = eZContentObjectTreeNode::classAttributeIDByIdentifier( $filterAttributeID );
$filterSQL = array();
$filterSQL['from'] = ", ezcontentobject_attribute i1 ";
$filterSQL['where'] = " (
i1.contentobject_id = ezcontentobject.id AND
i1.contentclassattribute_id = $filterAttributeID AND
i1.version = ezcontentobject_name.content_version AND
i1.language_code = ezcontentobject_name.real_translation AND
i1.data_text LIKE '%is_valid=\"1\"%' ) AND
";
return array( 'tables' => $filterSQL['from'], 'joins' => $filterSQL['where'] );
}
}
?>
sample fetch in template:
{let news_children = fetch(content,list,
hash( parent_node_id,85,
offset,0,
limit,1,
sort_by,array(published,false()),
class_filter_type,include,
class_filter_array,array(article),
main_node_only,true(),
extended_attribute_filter, hash( 'id', 'ExtendedImageFilter',
'params', hash( 'attribute', 'article/image' ) )
}
Hope that helps someone ... Contribution: http://ez.no/community/contribs/hacks/extended_attribute_filter_fetch_nodes_with_valid_images PS.: To eZ programer: Is there a better way to get the info, if a valid image is attached?
Best wishes,
Georg.
--
http://www.schicksal.com Horoskop website which uses eZ Publish since 2004
|