Forum

Thread tagged as: Question, Problem, Error

Custom Content Filtering Issue

Hi,

Not sure if i am missing something obvious here but i'm trying to filter some content to allow users to search through some factsheets that have a 'description' and 'keywords' field for each entry.

The options i'm passing to perch_content_custom are:

Array
(
    [template] => factsheet.html
    [page] => /factsheets-list.php
    [filter] => Array
        (
            [0] => Array
                (
                    [filter] => live
                    [match] => eq
                    [value] => live
                )

            [1] => Array
                (
                    [filter] => description
                    [match] => contains
                    [value] => test
                )

            [2] => Array
                (
                    [filter] => keywords
                    [match] => contains
                    [value] => test
                )

            [match] => or
        )

    [skip-template] => 1
    [return-html] => 1
)

The debug output i get when running this is:

Debug Message

SELECT setID FROM perch2_category_sets WHERE setSlug='factsheets' LIMIT 1

SELECT main.* FROM perch2_categories main WHERE 1=1 AND setID=2 ORDER BY catTreePosition ASC

Using template: /templates/categories/category.html

SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='Factsheets' AND (regionPage='/factsheets-list.php' OR regionPage='*')

SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=168 AND idx.itemRev=6)) AND ((idx.indexKey='live' AND idx.indexValue='live') OR (idx.indexKey='description' AND idx.indexValue REGEXP '[[:<:]]test[[:>:]]') OR (idx.indexKey='keywords' AND idx.indexValue REGEXP '[[:<:]]test[[:>:]]') OR (idx.indexKey='o' AND idx.indexValue='o')) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID HAVING count(*)=4 ORDER BY sortval ASC

Using template: /templates/content/factsheet.html

Array
(
    [type] => 2
    [message] => Illegal string offset 'value'
    [file] => PATH_TO_PERCH/core/apps/content/PerchContent.class.php
    [line] => 270
)
James Newton

James Newton 0 points

  • 5 years ago

James Newton said:

Hi,

Not sure if i am missing something obvious here but i'm trying to filter some content to allow users to search through some factsheets that have a 'description' and 'keywords' field for each entry.

The options i'm passing to perch_content_custom are:

Array
(
   [template] => 'factsheet.html',
   [page] => '/factsheets-list.php',
   [filter] => Array
       (
           [0] => Array
               (
                   [filter] => 'live',
                   [match] => 'eq',
                   [value] => 'live'
               )

           [1] => Array
               (
                   [filter] => 'description',
                   [match] => 'contains',
                   [value] => 'test'
               )

           [2] => Array
               (
                   [filter] => 'keywords',
                   [match] => 'contains',
                   [value] => 'test'
               )

           [match] => 'or',
       ),

   [skip-template] => 1,
   [return-html] => 1
)
Drew McLellan

Drew McLellan 2638 points
Perch Support

The 'match' option needs to be at the same level as 'filter', not as a child of it.

Original example was missing tons of single quotes and commas. I wondered about the 'match' option, so I left it alone in my reply ;(

Ah, thanks

Drew McLellan

Drew McLellan 2638 points
Perch Support

Robert - the original example was print_r() output.