Friday 21 November 2008 1:58:02 pm
Just an add-on ... If you want to search about items with object relation X or Y ... it's not possible with the previous extension (http://ez.no/developer/contribs/datatypes/enhanced_object_relation_filter ; very good work) but you can search about items with object relation X and Y ...
I have modified the main class : line 40, file 'eorfilter.php'
// multiple objects ids
if ( is_array($param[1]) )
{
// Treatment for 'and' parameters
if($param[2] == 'and')
{
foreach( $param[1] as $objectId )
{
if ( is_numeric( $objectId ) )
{
$tableName = 'eor_link_' . $objectId;
$tables[] = 'ezcontentobject_link ' . $tableName;
$joins[] = $tableName . '.from_contentobject_id = ezcontentobject.id';
$joins[] = $tableName . '.from_contentobject_version = ezcontentobject.current_version';
$joins[] = $tableName . '.contentclassattribute_id = ' . $classAttributeId;
$joins[] = $tableName . '.to_contentobject_id = ' . $objectId;
}
}
}
elseif($param[2] == 'or')
{
// Treatment for 'or' parameters
$cpt = 0;
$chaineCritere = "(";
foreach( $param[1] as $objectId )
{
if ( is_numeric( $objectId ) )
{
if($cpt == 0)
{
$tableName = 'eor_link_' . $objectId;
$tables[] = 'ezcontentobject_link ' . $tableName;
$joins[] = $tableName . '.from_contentobject_id = ezcontentobject.id';
$joins[] = $tableName . '.from_contentobject_version = ezcontentobject.current_version';
$joins[] = $tableName . '.contentclassattribute_id = ' . $classAttributeId;
$chaineCritere .= $tableName . '.to_contentobject_id = ' . $objectId;
}
else
{
$chaineCritere .= ' or '.$tableName . '.to_contentobject_id = ' . $objectId;
}
}
$cpt++;
}
$joins[] = $chaineCritere.")";
}
}
Now, it's possible to make an OR or AND search.
{def $listeOffre = fetch(content, list, hash(
'parent_node_id', 81,
'extended_attribute_filter', hash(
'id', 'eorfilter',
'params', array(
array('offre_emploi/pays', array(99,100,928), 'or'),
array('offre_emploi/niveau', array(97,98), 'or')
)
)))}
Greg
|