Exclude/include site areas for search results

Permalink
Hi guys,

I have 2 Search blocks on a website. One for "general" parts of the site (about us , products, etc.) and one for the Blog pages. Showing search results just for the blog pages is no problem. But excluding the blog pages for general search is a problem, because the blog is underneath the home page in page tree.

Any idea how to solve this?

Best regards

Torsten

tsilbermann
 
grosik replied on at Permalink Reply
grosik
http://www.concrete5.org/documentation/how-tos/developers/modify-site-search-block-to-search-through-product-titles-only-a/

take a look at this thread, it says how to filter search results by page type. so you can search only by pages you want to.
tsilbermann replied on at Permalink Reply
tsilbermann
This means I have to give all pages I'd like to have in "general" search an handle. Isn't there any way to exclude pages underneath a specific parent page (in this case underneath "blog")?
tsilbermann replied on at Permalink Reply
tsilbermann
Anyone?
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
I'm not sure which blog you are using. But in my case, I'm using Chad Strat's ProBlog. It has a default search page template. So if you use this add-on, you can choose the Custom Template to search only blog.

Rony
shahroq replied on at Permalink Best Answer Reply
shahroq
Put these lines at the:
\concrete\core\controllers\blocks\search.php [ver 5.6.1.2, do_search() method, line 218, before $res = $ipl->getPage();]
if($this->baseSearchPath == ''){
   $ipl->filter(false, "(p1.cParentID !=129)");
}

notes:
- change 129 to your blog parent page ID
- these filter operate when you select 'everywhere' on your search block.
tsilbermann replied on at Permalink Reply
tsilbermann
Thanks for the answer - I did that on search.php before line 218 (page ID is 129 as well), set search block to everywhere, cleared cache , reloaded database and search block, but it didn't work. The search results showing the pages underneath the blog page as well :-(
I have the search block in an global area - can that have affect to the changes?
Regards

Torsten
shahroq replied on at Permalink Reply
shahroq
No, placing the block on global area should not effect on behavior.
are you sure this is the controller system render, no override or something?
for tracking why it's not behave as predicted:
add a
print_r($ipl);

after or inside the the above code.
you should see new filter criteria (p1.cParentID !=129) in the result set like this:
[filters:protected] => Array
        (
            [2] => Array
                (
                    [0] => 
                    [1] => (p1.cParentID !=129)
                    [2] => =
                )
        )
tsilbermann replied on at Permalink Reply
tsilbermann
I forgot that the site is updated... changing the right search.php made it :-) Thanks for your solution.
Might there be a way without a core hack, so I don't have to change search.php after every update?

Best Regards

Torsten
shahroq replied on at Permalink Reply
shahroq
yep, the right way to do is override controller, not changing core file.
for more info about overriding check the documentation.