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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 16:12:03
Script start
Timing: Jan 18 2025 16:12:03
Module start 'layout'
Timing: Jan 18 2025 16:12:03
Module start 'content'
Timing: Jan 18 2025 16:12:03
Module end 'content'
Timing: Jan 18 2025 16:12:03
Script end

Main resources:

Total runtime0.0155 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 592.2266152.6406
Module start 'layout' 0.00640.0027 744.867239.4766
Module start 'content' 0.00910.0043 784.343893.3984
Module end 'content' 0.01340.0021 877.742238.3047
Script end 0.0155  916.0469 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002415.4412140.0002
Check MTime0.00117.0560140.0001
Mysql Total
Database connection0.00117.372610.0011
Mysqli_queries0.003119.958830.0010
Looping result0.00000.096810.0000
Template Total0.001710.910.0017
Template load0.00095.620910.0009
Template processing0.00085.259810.0008
Override
Cache load0.00064.099610.0006
General
dbfile0.00031.618080.0000
String conversion0.00000.053840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs