Coroico / AdvSearch

Dynamic content search add-on for MODx Revolution that supports results highlighting, faceted search and search in custom packages
21 stars 14 forks source link

Add the ability to exclude certain resources and their children #42

Closed oo12 closed 11 years ago

oo12 commented 11 years ago

Hi, thanks for this great extra!

It'd be nice if it had an &exclude property, similar to simpleSearch. &exclude could be a comma-separated list of resource IDs exclude from the search. Their children would also be excluded.

Sometimes there's a part of the resource tree which I don't want showing up in the search results. Yes, I could hide the resources from the menu and set hideMenu to 0, but I'm also using Articles and all blog posts are hidden (so &hideMenu=0 effectively turns off search for a blog).

Coroico commented 11 years ago

By using the GetIds snippet ( http://modx.com/extras/package/getids ), you probably can solve your request.

Apologies, the demo site is still under construction. But the add-on description is in my opinion enough to understand how to use it.

SnowCreative commented 8 years ago

Adding the ability to exclude certain ids (not including children) is simple. I added this to line 36 of advsearch.mysql.controller.class.php in the controllers folder:

    // exclude ids
    if (!empty($this->config['exclude'])) {
        $excludeids = array_map('trim', @explode(',', $this->config['exclude']));
        $c->where(array(
            'modResource.id:NOT IN' => $excludeids
        ));
    }

Then I can use
&exclude='(ids here)'

in the parameters