Forum
Filter by multiple fields + User-filtered list
Is it possible to filter by multiple fields if you're already using a user-filtered list?
perch_content_custom('Dogs', array(
'template' => 'dog_listing.html',
'sort' => 'date-added',
'sort-order' => 'DESC',
'paginate' => true,
'page-links' => true,
'page-link-template' => 'page-links-custom.html',
'count' => 12,
'filter'=>[
[
'filter'=>$filters,
],
[
'filter'=>'hide',
'match'=>'neq',
'value'=>'hide',
],
]
));
The first filter, 'filter'=>$filters,
, is from the User-filtered list tutorial. The second filter is a Perch ID that I'm using to hide/unpublish content (I'm using a checkbox).
This is the error I get when the code runs:
Notice: Undefined index: value in /Users/matthewsanchez/Dropbox/narf-local/perch/core/apps/content/PerchContent.class.php on line 270
Btw, I think there's an extra semicolon in the first code block under 'Filtering by multiple fields' on the perch_content_custom() page.
Diagnostics:
PHP 7.0.13 is up to date
MySQL 5.6.34 is up to date
Image processing available
Summary information
Perch: 3.0.1, PHP: 7.0.13, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: 241ae00989d1995ffcbbf63d579943635faf9972 $, with PDO
Server OS: Darwin, apache2handler
Installed apps: content (3.0.1), assets (3.0.1), categories (3.0.1), perch_events (1.9.5), perch_forms (1.9)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_forms', 'perch_events', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /Users/matthewsanchez/Dropbox/narf-local/perch
PERCH_CORE: /Users/matthewsanchez/Dropbox/narf-local/perch/core
PERCH_RESFILEPATH: /Users/matthewsanchez/Dropbox/narf-local/perch/resources
Image manipulation: GD
PHP limits: Max upload 32M, Max POST 32M, Memory: 128M, Total max file upload: 32M
F1: 0c66c2e1f82f9e0b7617b2cb8270f2c7
Resource folder writeable: Yes
HTTP_HOST: localhost:8888
DOCUMENT_ROOT: /Users/matthewsanchez/Dropbox/narf-local
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
$filters
itself is an array of filters. You'll want to add your additional filter to the array, and then call all filters at once. Remove theif (!count($filters)) $filters=false;
line from the tutorial code and replace yourperch_content_custom
with this:Thanks Shane! Your solution was spot on.