Forum

Thread tagged as: Question, Docs

Utilize perch_content_search with array of content, or exclude a singular path/p...

Hello again,

Today I have a new issue that I'm researching. In that my client is asking me to remove a section of their site from the perch_content_search's consideration due to it being password protected. After reviewing the perch_content_search documentation, and the change log from November 17th of last year I'm left a little confused on how to complete this. The only usage example I see in the grabaperch docs site (https://docs.grabaperch.com/functions/search/perch-content-search/) is:

<?php
  $query = perch_get('q');
  perch_content_search($query, array(
    'count'=>5,
    'from-path'=>'/articles',
    'excerpt-chars'=>300,
    'template'=>'my_template.html'
  ));
?>

Am I to assume that the correct way to use the array functionality is to write it like this?

<?php
  $query = perch_get('q');
  perch_content_search($query, array(
    'count'=>5,
    'from-path'=>array('/articles', '/news', '/blog'),
    'excerpt-chars'=>300,
    'template'=>'my_template.html'
  ));
?>

Secondly because the client is asking me to remove a particular section from search, is there a way of either marking it, or changing the search function to pass over that folder short of exhaustively listing all the other content paths on the site? Strangely enough, the one they want to remove is sheltered inside a folder that I suspect they want searchable.

Ie. /searchablefolder/unsearchablefolder

Is there a way to say that anything that matches that path should be ignored? It would make the difference between writing 1 line and writing 30 lines in this case.

D Budgell

D Budgell 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

There's a checkbox in the region options to exclude the content from search.

Oh... Is it really that simple? I just spent two hours writing up an exhaustive sitemap into the search function!

Now I have egg on my face. Ouch.

I'll try it out.

Yeah it works better than the sitemap search I had come up with. I really need to become more familiar with the options that Perch dashboard gives me.