eZ Community » Forums » Developer » attribute filter for fetching special...
expandshrink

attribute filter for fetching special character,numeric,# records in template

attribute filter for fetching special character,numeric,# records in template

Saturday 03 March 2012 6:22:53 am - 9 replies

Hi i need to fetch the records  title start with numeric ,special character,#  in templates for this i  need to pass attribute_filter value in the fetch function currently i am writing 3 diffrent fetch call

1. numeric title

2.special characte title

3.blank  space title

    Is it possible to  use only one fetch function instead of 3 ,

 

Please help me out to overcome  this problem

 

Thank's in  advance to all

Saturday 03 March 2012 8:53:03 am

You can have several matches in the attributre_filter array. These matches are carried out with either "and" or "or" condition.

So I guess what you need is something like

 'attribute_filter', array ( 'or', array( 'title', 'like', '#*'), array(<condition2>), array(<condition3>)))

Modified on Saturday 03 March 2012 8:54:04 am by Olivier Clavel

Monday 05 March 2012 2:00:07 pm

Hi Oliver i try this but it's not working pls chk my code

'attribute_filter', array( 'or', array('article/archive_status', '=', 0), array('article/publish_date', '<=', currentdate()), array('article/title', '>=', 0), array('article/title', '<=', 9), array('article/title', 'like', concat('#*') )

 

there is some data that start with # and space also.

Tuesday 06 March 2012 4:30:05 pm

Hello Jignesh,

Why are you doing a "concat" in the last filter ? Try:

 array( 'article/title', 'like', '#*')

Have you some error in the debug output ?

Wednesday 07 March 2012 9:28:28 am

Is it possible to use "regexp" insted of "like" is possible please provide some example

Wednesday 07 March 2012 11:03:11 am

Quote from Jignesh Sailor :

Is it possible to use "regexp" insted of "like" is possible please provide some example

Hi,

Built'in operator for attribute filtering are here:

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

if none of these can match your case, You may create your extended_attribute_filter

NB: there's an example at the bottom of the page, on how to create an extended_attribute_filter.

if you have question about how to create it, you can post it here... blunk.gif Emoticon

Modified on Wednesday 07 March 2012 11:05:10 am by Ousmane KANTE

Friday 09 March 2012 6:06:52 am

Quote from Ousmane KANTE :
Quote from Jignesh Sailor :

Is it possible to use "regexp" insted of "like" is possible please provide some example

Hi,

Built'in operator for attribute filtering are here:

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

if none of these can match your case, You may create your extended_attribute_filter

NB: there's an example at the bottom of the page, on how to create an extended_attribute_filter.

if you have question about how to create it, you can post it here... blunk.gif Emoticon

Hi Ousmane i  am new to ezpublish so is it poassible to create extended attribute filter for my requirement, i also want ot know how to print sql query for fetch  so that i can know what  type of sql query is been used i enable the SQLoutput in "site.ini.append.php" but it did't shoq me any query 

Friday 09 March 2012 11:25:49 am

Quote from Jignesh Sailor :
Quote from Ousmane KANTE :
Quote from Jignesh Sailor :

Is it possible to use "regexp" insted of "like" is possible please provide some example

Hi,

Built'in operator for attribute filtering are here:

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

if none of these can match your case, You may create your extended_attribute_filter

NB: there's an example at the bottom of the page, on how to create an extended_attribute_filter.

if you have question about how to create it, you can post it here... blunk.gif Emoticon

Hi Ousmane i  am new to ezpublish so is it poassible to create extended attribute filter for my requirement, i also want ot know how to print sql query for fetch  so that i can know what  type of sql query is been used i enable the SQLoutput in "site.ini.append.php" but it did't shoq me any query 

Hi,

Not sure to really understand your post.

Do you want to create an extended_attribute_filter?

 

For showing Sql output in debug, I think should first enable 'DebugOutput' in DebugSettings section in your 'site.ini'. (enable debug output)

Then enable SQLOupt in DataBaseSettings section.

Hope that can Help you

blunk.gif Emoticon

Friday 09 March 2012 2:21:03 pm

Quote from Ousmane KANTE :
Quote from Jignesh Sailor :
Quote from Ousmane KANTE :
Quote from Jignesh Sailor :

Is it possible to use "regexp" insted of "like" is possible please provide some example

Hi,

Built'in operator for attribute filtering are here:

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

if none of these can match your case, You may create your extended_attribute_filter

NB: there's an example at the bottom of the page, on how to create an extended_attribute_filter.

if you have question about how to create it, you can post it here... blunk.gif Emoticon

Hi Ousmane i  am new to ezpublish so is it poassible to create extended attribute filter for my requirement, i also want ot know how to print sql query for fetch  so that i can know what  type of sql query is been used i enable the SQLoutput in "site.ini.append.php" but it did't shoq me any query 

Hi,

Not sure to really understand your post.

Do you want to create an extended_attribute_filter?

 

For showing Sql output in debug, I think should first enable 'DebugOutput' in DebugSettings section in your 'site.ini'. (enable debug output)

Then enable SQLOupt in DataBaseSettings section.

Hope that can Help you

blunk.gif Emoticon

i want to create extended_attribute_filter

Friday 09 March 2012 5:03:52 pm

Hi

Just take the example 20 on the page above (ie http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Modules/content/Fetch-functions/list)

 

then you just have to replace the SQL code with your own.

something like that :

 

class myRegexpExtendedAttributeFilter{

.....

function sqlParts( $parameters )
    {
        $sqlTables= ', ezcontentobject_attribute as myregexp_alias ';
        $sqlJoins = ' ezcontentobject_tree.contentobject_id = myregexp_alias.contentobject_id AND ' .
                    ' ezcontentobject_tree.contentobject_version = myregexp_alias.version AND '.
                    ' myregexp_alias.identifier = "title"  AND ';
        $sqlJoins .= eZContentLanguage::sqlFilter( "myregexp_alias", 'ezcontentobject' ). ' AND ';// for multi lang...
        $sqlCond = ' myregexp_alias.data_text regexp( "'. $paramters . '" ) AND ' . $sqlJoins . ' ';
        return array( 'tables' => $sqlTables, 'joins' => $sqlCond );
    }

....

}

and your template code should looks like

 

fetch('content', 'list', hash('parent_node_id', $node_id, 'class_filter_type', 'include', 'class_filter_array', array('article'), 'extended_attribute_filter', hash('id', 'myRegExpFilter', 'params', 'your_regexp')))}

 

extendedattributefilter.ini looks like

[myRegExpFilter]
ClassName=myRegexpExtendedAttributeFilter
MethodName=sqlParts

Test it

Modified on Friday 09 March 2012 5:07:01 pm by Ousmane KANTE

expandshrink

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

36 542 Users on board!

Forums menu