Forum

Thread tagged as: Question, Problem, Error

Search only in specific pages

Hello,

I am trying to get my search form to only search in my.domain.nl/nieuws.

      $query = perch_get('q');
      perch_content_search($query, array(
        'count'       => 5,
                'from-path'=>'/nieuws',
      ));

This is the code on my searchresults.php page, but it is giving me results from all pages. It should be fairly easy, what am I doing wrong?

Mike

Mike Hendriks

Mike Hendriks 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

I can't see anything wrong. Can you show me the debug output for the search result?

Debug Message - Perch Runway 3.0.13
[33] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate, pr.routeOrder, s.settingValue AS siteOffline FROM perch3_pages p LEFT JOIN perch3_page_routes pr ON p.pageID=pr.pageID LEFT JOIN perch3_settings s ON s.settingID='siteOffline' UNION SELECT NULL AS pagePath, pr2.routePattern, pr2.routeRegExp, pr2.templatePath AS pageTemplate, pr2.routeOrder, NULL AS siteOffline FROM perch3_page_routes pr2 WHERE templateID!=0 ORDER BY routeOrder ASC, pagePath ASC
Matched page: /zoekresultaten, so not using routes.
Using master page: /templates/pages/zoekresultaten.php
[36] SELECT DISTINCT settingID, settingValue FROM perch3_settings WHERE userID=0
[1] SELECT * FROM perch3_pages WHERE pagePath='/zoekresultaten' LIMIT 1
Using template: /templates/pages/attributes/default.html
Using sub-template: /templates/pages/attributes/seo.html
Using sub-template: /templates/pages/attributes/facebook.html
Using sub-template: /templates/pages/attributes/twitter.html
Using template: /templates/search//search-form.html
[8] SELECT * FROM perch3_pages WHERE pageNew=0 AND pageHidden=0 AND pageDepth >=0 AND pageDepth<=1 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch3_pages WHERE pagePath='/zoekresultaten' LIMIT 1
[1] SELECT pageID FROM perch3_pages WHERE pageTreePosition IN ('000-010', '000') ORDER BY pageTreePosition DESC
[8] Using template: /templates/navigation/item.html
Search term: westland
[5] SELECT SQL_CALC_FOUND_ROWS DISTINCT 'PerchContent_SearchHandler' AS source, MATCH(ci.itemSearch) AGAINST('westland') AS score, r.regionPage AS col1, ci.itemSearch AS col2, ci.itemJSON AS col3, r.regionOptions AS col4, p.pageNavText AS col5, p.pageTitle AS col6, regionTemplate AS col7, r.regionKey AS col8 FROM perch3_content_regions r, perch3_content_items ci, perch3_pages p WHERE r.regionID=ci.regionID AND r.regionRev=ci.itemRev AND r.pageID=p.pageID AND r.regionPage!='*' AND r.regionSearchable=1 AND (MATCH(ci.itemSearch) AGAINST('westland') OR MATCH(ci.itemSearch) AGAINST('westland') ) AND (r.regionPage LIKE '/nieuws%') UNION SELECT 'PerchContent_RunwaySearch' AS source, MATCH(ci.itemSearch) AGAINST('westland') AS score, c.collectionKey AS col1, ci.itemSearch AS col2, ci.itemJSON AS col3, c.collectionOptions AS col4, c.collectionKey AS col5, c.collectionKey AS col6, collectionTemplate AS col7, c.collectionKey AS col8 FROM perch3_collections c, perch3_collection_items ci, perch3_collection_revisions cr WHERE c.collectionID=cr.collectionID AND cr.itemID=ci.itemID AND cr.itemRev=ci.itemRev AND c.collectionSearchable=1 AND cr.itemSearchable=1 AND (MATCH(ci.itemSearch) AGAINST('westland') OR MATCH(ci.itemSearch) AGAINST('westland') ) UNION SELECT 'PerchBlog_SearchHandler' AS source, MATCH(postTitle, postDescRaw, postTags) AGAINST('westland') AS score, postTitle, postSlug, postDateTime, postDescHTML, postID, sectionSlug, "", "" FROM perch3_blog_posts p, perch3_blog_sections s WHERE postStatus='Published' AND postDateTime<'2018-01-24 09:08:15' AND p.sectionID=s.sectionID AND MATCH(postTitle, postDescRaw, postTags) AGAINST('westland') UNION SELECT 'PerchEvents_SearchHandler' AS source, MATCH(eventTitle, eventDescRaw) AGAINST('westland') AS score, eventTitle, eventSlug, eventDateTime, eventDescHTML, eventID, "", "", "" FROM perch3_events WHERE eventDateTime>'2018-01-24 09:08:15' AND MATCH(eventTitle, eventDescRaw) AGAINST('westland') ORDER BY score DESC LIMIT 0, 5
[18] SELECT FOUND_ROWS() AS `count`
[5] Using template: /templates/search/search-result.html
[3] SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM perch3_blog_index idx JOIN perch3_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN perch3_blog_index idx2 ON idx.itemID=idx2.itemID AND idx.itemKey='postID' AND idx2.indexKey='postDateTime' WHERE 1=1 AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey GROUP BY idx.itemID, idx2.indexValue, postID ) as tbl WHERE (postStatus='Published' AND postDateTime<='2018-01-24 09:08:00' ) GROUP BY itemID, sortval ORDER BY sortval DESC LIMIT 0, 3
[1] SELECT FOUND_ROWS() AS `count`
[3] Using template: /templates/blog/sidebar_recente_posts.html
[2] SELECT * FROM perch3_blog_sections ORDER BY sectionTitle ASC
[1] SELECT * FROM perch3_blogs ORDER BY blogTitle ASC
Array
(
    [type] => 8
    [message] => date_default_timezone_set(): Timezone ID 'UTC+1' is invalid
    [file] => /home/lpfwstlnd/domains/lpfwestland.nl/public_html/perch/core/runtime/loader.php
    [line] => 24
)
Request time: 0,1344
Process time: 0,1333
Memory: 3,8002
Array
(
    [type] => 8
    [message] => date_default_timezone_set(): Timezone ID 'UTC+1' is invalid
    [file] => /home/lpfwstlnd/domains/lpfwestland.nl/public_html/perch/core/runtime/loader.php
    [line] => 24
)
Drew McLellan

Drew McLellan 2638 points
Perch Support

That is searching for regions on pages beginning with /nieuws. Can you give an example of content from other pages that it's returning?