Section show based on 'eq' and 'and' not working

Author Message

K259

Tuesday 06 December 2005 3:28:22 pm

I try only list content for contentclass_id 25, 21 and 6, but the code is not working.

{section show=eq(and($SearchResult:item.object.contentclass_id|eq(25),$SearchResult:item.object.contentclass_id|eq(21),$SearchResult:item.object.contentclass_id|eq(6)))}

I also tried this code:

{section show=eq($SearchResult:item.object.contentclass_id,25)}
{section show=and(eq($SearchResult:item.object.contentclass_id,21))}

But this is also not working..I have this in production another place, and it works.
Can anyone see what's my error here?
:/ Been messing around with this too many hours now.

Łukasz Serwatka

Tuesday 06 December 2005 11:12:05 pm

I try only list content for contentclass_id 25, 21 and 6

Try with:

{let class_ids=array(25, 21, 6)}
{section show=$class_ids|contains($SearchResult:item.object.contentclass_id)}
   display only for classes with ids 25, 21, 6
{/section}
{/let}

It is doing the same and it is easy to maintain, if need display more classes just add ids to array. However, you can specify which classes you wan to search, look on search function.
http://ez.no/doc/ez_publish/technical_manual/3_6/reference/modules/content/fetch_functions/search

Good examples of usage eq, and also other operators you can find in documentation.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

K259

Wednesday 07 December 2005 1:07:32 am

Hi! Tnx.
This will also work with v.3.4.x?

Łukasz Serwatka

Wednesday 07 December 2005 1:08:35 am

Yes, it should works on 3.4.x

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

K259

Thursday 08 December 2005 3:27:35 am

Hi Lukasz!
I've still not solved this problem..your example worked (so tnx 2 u), but I can't still complete my task with the grouping of the searchresult with ezsearch.

Displayed through this code is only the first section with website, chapters and links viewable. The articles of class 2 are not beeing listed. Do you know why? Is it possible to use $SearchResult only once in a loop?

{section show=$search_text}
{switch name=Sw match=$search_count}
  {case match=0}
<h2>No results for: "{$search_text|wash}"</h2>
  {/case}
  {case}
<h2>{$search_count} hits for {$search_text|wash}</h2>
  {/case}
{/switch}
{* start list results for website,chapters and links *}
{let class_ids=array(25, 21, 6)} 
 <table class="list" width="100%" border="0" cellspacing="0" cellpadding="0">
  {section name=SearchResult loop=$search_result show=$search_result sequence=array(bglight,bgdark)}
  {section show=$class_ids|contains($SearchResult:item.object.contentclass_id)} 
{run-once}
<tr><td><h2>Mixed content</h2></td></tr>
{/run-once}
<tr>
       <td class="{$SearchResult:sequence}"><a href={$SearchResult:item.url_alias|ezurl}">{$SearchResult:item.name|wash}</a>
      </td>
</tr>
  {/section}
  {/section}
  </table>
  {/let}
  {* end list results for website,chapters and links *}
  {* start list results for articles *}
  {let class_idsa=array(2)} 
   <table class="list" width="100%" border="0" cellspacing="0" cellpadding="0">
    {section name=SearchResult loop=$search_result show=$search_result sequence=array(bglight,bgdark)}
    {section show=$class_idsa|contains($SearchResult:item.object.contentclass_id)} 
  {run-once}
  <tr><td><h2>Articles</h2></td></tr>
{/run-once}
  <tr>
         <td class="{$SearchResult:sequence}"><a href={$SearchResult:item.url_alias|ezurl}">{$SearchResult:item.name|wash}</a>
        </td>
  </tr>
    {/section}
    {/section}
    </table>
  {/let}
  {* end list results for articles *}
  {/section}

..as I told you earlier, I want to list:
"topic"
list websites, chapters, links (list only 10 items of these classes at the first page)
and under here:
"topic"
list articles (list only 10 items of this class at the first page)..

The point is to group the searchresults, and not list everything in just a mix.

Hope someone can help me out with this :(

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:05:47
Script start
Timing: Jan 18 2025 16:05:47
Module start 'layout'
Timing: Jan 18 2025 16:05:47
Module start 'content'
Timing: Jan 18 2025 16:05:48
Module end 'content'
Timing: Jan 18 2025 16:05:48
Script end

Main resources:

Total runtime0.6672 sec
Peak memory usage4,096.0000 KB
Database Queries63

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0046 589.1641152.6406
Module start 'layout' 0.00460.0024 741.804739.4766
Module start 'content' 0.00700.6589 781.2813571.0234
Module end 'content' 0.66590.0013 1,352.304716.1250
Script end 0.6671  1,368.4297 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00300.4494160.0002
Check MTime0.00120.1821160.0001
Mysql Total
Database connection0.00070.107210.0007
Mysqli_queries0.615392.2305630.0098
Looping result0.00060.0890610.0000
Template Total0.640996.120.3204
Template load0.00230.339820.0011
Template processing0.638695.715420.3193
Template load and register function0.00020.035110.0002
states
state_id_array0.00070.110510.0007
state_identifier_array0.00100.143820.0005
Override
Cache load0.00190.2842370.0001
Sytem overhead
Fetch class attribute can translate value0.00060.093120.0003
Fetch class attribute name0.00110.162260.0002
XML
Image XML parsing0.00080.125420.0004
class_abstraction
Instantiating content class attribute0.00000.002270.0000
General
dbfile0.00070.1070180.0000
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 28
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs