Sunday 01 March 2009 11:32:19 pm
I create a class for extended_attribute_filter to fetch relative author object:
class HHAuthorFilter
{
function HHAuthorFilter()
{
// Empty...
}
function createSqlParts( $params )
{
$sqlTables= ', ezcontentobject_attribute as myfilter_alias ';
$sqlJoins = ' ezcontentobject_tree.contentobject_id = myfilter_alias.contentobject_id AND ezcontentobject_tree.contentobject_version = myfilter_alias.version AND myfilter_alias.data_type_string = "ezauthor" AND';
$sqlCondArray = array();
foreach($params as $value)
{
$sqlCondArray[] = 'myfilter_alias.data_text LIKE "%' . $value[2] . '%"';
}
$sqlCond = implode( ' OR ', $sqlCondArray );
$sqlCond = ' ( ' . $sqlCond . ' ) AND ' . $sqlJoins . ' ';
return array( 'tables' => $sqlTables, 'joins' => $sqlCond );
}
}
in template we got the $node.data_map.author.content.author_list as array, and this is the syntax in template:
{def $posts = fetch( 'content', 'list',
hash( 'parent_node_id', 2,
'sort_by', array( 'priority', false() ),
'limit', 5,
'extended_attribute_filter',
hash( 'id', 'HHAuthorFilter',
'params', hash( $node.data_map.author.content.author_list ) ) ) )}
{foreach $posts as $post}
{$post.name|wash()}
{/foreach}
{undef $posts}
but the sql string I got:
( ) AND ezcontentobject_tree.contentobject_id = myfilter_alias.contentobject_id AND ezcontentobject_tree.contentobject_version = myfilter_alias.version AND myfilter_alias.data_type_string = "ezauthor"
I known the error must be in $params I send from template or wrong in use array in my extended filter class. Please help me! I use this method to fetch the other object by current node's author.
|