Forum

Thread tagged as: Question, Problem

Perch Blog Custom contains

Hi,

Im seeing issues when using 'match' => 'contains',

I don't get any output and any advice be great.

                        <?php perch_blog_custom(array(
                            'filter' => 'postTitle',
                            'match' => 'contains',
                            'value' => 'Bedlam Brewery',
                            'section' => 'case-study',
                            'template' => 'post_in_list--home.html',
                            'count'=> 2,
                        ));
                        ?>

However the below works

                        <?php perch_blog_custom(array(
                            'filter' => 'postTitle',
                            'match' => 'eq',
                            'value' => 'Bedlam Brewery',
                            'section' => 'case-study',
                            'template' => 'post_in_list--home.html',
                            'count'=> 2,
                        ));
                        ?>

I also see the below in the debug:

DIAGNOSTICS: SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/index.php' OR regionPage='' ORDER BY regionPage DESC SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='item' AND (regionPage='/digital/index.php' OR regionPage='/print/index.php' OR regionPage='/marketing/index.php' OR regionPage='/branding/index.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='13' AND idx.itemRev='21') OR (idx.regionID='12' AND idx.itemRev='19') OR (idx.regionID='11' AND idx.itemRev='51') OR (idx.regionID='10' AND idx.itemRev='55')) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID ORDER BY sortval ASC LIMIT 0, 4 Using template: /templates/content/item--home.html SELECT * FROM perch2_blog_sections WHERE sectionSlug='case-study' LIMIT 1 SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0 SELECT SQL_CALC_FOUND_ROWS DISTINCT p.* FROM perch2_blog_posts p WHERE postStatus='Published' AND postDateTime<='2014-10-02 13:24:00' AND postTitle REGEXP '[[:<:]]'.Bedlam Brewery.'[[:>:]]' AND sectionID='2' LIMIT 0, 2 Invalid query: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.Bedlam Brewery.'[[:>:]]' AND sectionID='2' LIMIT 0, 2' at line 1 SELECT FOUND_ROWS() AS count Using template: /templates/blog/post_in_list--home.html

Steve Forbes

Steve Forbes 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Which version of Perch and Blog are you running?

Hi Drew

Perch 2.6.3 and blog perch_blog (4.1)

Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you try with the latest?

Upgraded Both and now works all good, Should i be able to pass an array to 'contains' => array('news', 'announcements'),

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, that should work.

sorry i meant 'value' => array('news', 'announcements'),

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ah, I see. Nope.