Forum

Thread tagged as: Question, Problem

Perch Content Custom filter out current page

Hi,

Im using perch_content_custom to display a list of items on a page but I want to filter out the current page so it doesn't show in the list of items.

I've tried filtering by id="_page" and using perch_page_url to get the url/slug of the current page and set the filter to not equal, but it's not working. Am I missing something obvious or is there a better way to do this?

Will post my content_custom, template and debug code:

Content Region:

<?php

      $url = perch_page_url([
          'include-domain' => false,
        ], true);

        perch_content_custom('Banner and Copy', [
          'filter'=>'_page',
          'match'=>'neq',
          'value'=>$url,
          'page'=>'/case-studies/*',
          'template'=>'case_list_home.html',
          // 'sort'=>'date',
          // 'sort-order'=>'DESC',
          'count'=>3
        ]);
      ?>

Template:

<a href="<perch:content id="_page">" class="case--study" style="background-image: url('<perch:content id="case_banner" />');">
  <div class="case--study-title"><perch:content id="case_title" /></div>
</a>

Debug:

Debug Message - Perch 3.1.3
[4] SELECT regionKey, regionHTML FROM perch3_content_regions WHERE regionPage='/case-studies/bradburys.php' OR regionPage='*' ORDER BY regionPage DESC
[4] SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch3_content_regions WHERE regionKey='Banner and Copy' AND (regionPage LIKE '/case-studies/%' OR regionPage='*')
[nil] SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch3_content_index idx JOIN perch3_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch3_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=2 AND idx.itemRev=6) OR (idx.regionID=6 AND idx.itemRev=2) OR (idx.regionID=10 AND idx.itemRev=2) OR (idx.regionID=14 AND idx.itemRev=4)) AND ((idx.indexKey='_page' AND idx.indexValue != '/case-studies/bradburys.php')) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, pageID, itemJSON, sortval, regionID ORDER BY sortval ASC LIMIT 0, 3
Using template: /templates/content/case_list_home.html
ewe agency

ewe agency 0 points

  • 2 years ago