Forums / Setup & design / get class id for search from content browse

get class id for search from content browse

Author Message

David Suela

Monday 16 October 2006 6:54:32 am

Hi!

I need to add search function to the content browse admin of an object relation attribute. Everything ok, except that i can't filter search by class id. The $browse variable have the class name, but not the class_id of the object relation. How can i get the class_id of the object relation?

For example, if i can only relation objects of class foo, i have to search all objects, i can't only search for foo objects.

Thanks in advance,

David.

xsto.info <el acceso a la información>
http://xsto.info
http://dominios.coop

Kristof Coomans

Tuesday 17 October 2006 12:06:57 am

Hello David

Are you using $browse.class_array? It indeed is an array with content class identifiers. And the content/search fetch function expects an ID or an array of ID's.

You can loop over the $browse.class_array, fetch the class and build an array with class id's:

{def $classIDList=array()}

{foreach $browse.class_array as $classIdentifier}
  {def $class=fetch('content', 'class', hash( 'class_id', $classIdentifier ))}
    {set $classIDList=$classIDList|append($class.id)}
  {undef $class}
{/foreach}

{* place search code here *}

{undef $classIDList}

Can you share your template when it's finished? That would be a nice contribution ;-)

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

David Suela

Wednesday 18 October 2006 12:44:48 am

Hi!

I'll try your code this week, it's what i looking for, thanks.

I hope to finish (and clean) the template this weekend and then share it. Now the template is a caos of commentaries and loops and ...

Thanks a lot,

David.

xsto.info <el acceso a la información>
http://xsto.info
http://dominios.coop

David Suela

Friday 27 October 2006 9:04:24 am

Hi!

Your solution works perfect. I upload the template to http://ez.no/community/contribs/hacks/search_form_in_admin_content_browse_tpl

One thing more, how can i override this template?

xsto.info <el acceso a la información>
http://xsto.info
http://dominios.coop

Kristof Coomans

Friday 27 October 2006 10:03:14 am

Do you want to replace the default one with yours from inside an extension?

Or do you want to override it when certain conditions are met? See http://ez.no/doc/ez_publish/technical_manual/3_8/reference/template_override_conditions content/browse.tpl

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org