Forums / Developer / Section show based on 'eq' and 'and' not working

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 :(

eZ debug

Timing: Jan 18 2025 11:07:09
Script start
Timing: Jan 18 2025 11:07:09
Module start 'content'
Timing: Jan 18 2025 11:07:10
Module end 'content'
Timing: Jan 18 2025 11:07:10
Script end

Main resources:

Total runtime1.6143 sec
Peak memory usage4,096.0000 KB
Database Queries200

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0068 587.8438180.8125
Module start 'content' 0.00681.4502 768.6563576.1172
Module end 'content' 1.45700.1572 1,344.7734337.3672
Script end 1.6142  1,682.1406 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00440.2747210.0002
Check MTime0.00160.1009210.0001
Mysql Total
Database connection0.00080.047110.0008
Mysqli_queries1.534395.04482000.0077
Looping result0.00220.13861980.0000
Template Total1.576597.720.7883
Template load0.00250.154520.0012
Template processing1.574097.507020.7870
Template load and register function0.00020.010910.0002
states
state_id_array0.00150.092710.0015
state_identifier_array0.00190.116120.0009
Override
Cache load0.00200.1268370.0001
Sytem overhead
Fetch class attribute can translate value0.00140.088330.0005
Fetch class attribute name0.00140.087560.0002
XML
Image XML parsing0.00100.059230.0003
class_abstraction
Instantiating content class attribute0.00000.000870.0000
General
dbfile0.00300.1869290.0001
String conversion0.00000.000530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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