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.