Search not working?

Permalink 1 user found helpful
Hi there!

In my theme I got a fixed call for the search (Version

$bt_search->controller->buttonText = "GO";
$bt_search->controller->title = "Search";
$bt_search->controller->resultsURL = "/search-results";

I also reindexed in the backend the search tables.

If I search for an element in the navigation (e.g: contact) everything works as it should. The result is shown.

But if I search for anything else it doesn't show up. I have for example the text "download" on a page in the sublevel and if I search for "download" it shows me "0" results.

Am I doing something wrong or is the search buggy?

I also added a search in edit mode just to be sure that I don't have a bug in my call, but I get the same result.

View Replies: View Best Answer
jordanlev replied on at Permalink Best Answer Reply
I think the search code only looks at content inside an area called 'Main' or 'Main Content'. If the content you're searching for is in an area with a different name, then it won't come up. Here's instructions on how to change that (assuming that's the problem):
Mnkras replied on at Permalink Reply
personally i use html
<form action="<?=$this->url('search-results')?>" method="get"> 
<input name="search_paths[]" type="hidden" value="" /> 
<input name="query" type="text" class="search-block-input" value="" /> 
<input name="submit" type="submit" class="search-block-submit" value=">" /> 
<div class="clear"></div>
Kiesel replied on at Permalink Reply
Thank you both for the answers!

Okay, in order to get my search working I had to do the following:

1. copy concrete/jobs/index_search.php to jobs/index_search.php and add the following line $is->addSearchableArea('content_inner');
before: $result = $is->reindexAll();

So my whole page gets indexed (I see no reason why I ever would wanna only a part indexed), cause I have an div #content_inner wrapped around all my content

2. I went to /dashboard/sitemap/search/manage_index/ and choose "blacklist" so - again - everything gets indexed

3. I indexed everything again (dashboard/system/jobs/).

And voilà: Finally my "Welcome" on the first page got found by searching "Welcome".

Honestly I think that is an overkill just to get your search running. I think at least point 1 should add the whole "body" and 2. should be on blacklist by a new install.

And it seems not to work correctly anyways. I could search and find elements from the navigation, and in relation to point 1 + 2 the navigation did not meet the requirements to be found.
jordanlev replied on at Permalink Reply
Thanks for posting your solution back here -- it will come in handy if anyone has this problem in the future.

As for why you might want to index only part of a page -- I think the logic here is that sidebar and footer content shouldn't be searchable, because it usually appears on lots of different pages so you wouldn't want every page coming up if the search term happened to be in a common sidebar block (like one that was added with the "page defaults"). Not saying that's the right thing to do for all sites, but I can understand where they're coming from.

And as for searching terms in the navigation area -- do you mean people should be able to search for page names or titles? Again, this sounds like it should be a lot easier, but if it's not working you could try adding the page titles to the content of each page (like in an <h1> element). Or I just saw a new free block in the marketplace that automatically outputs page titles (and other info like author and date) -- you could put that in the page defaults and modify the index_search.php file again to include whatever area that's in as well.

Best of luck.

Kiesel replied on at Permalink Reply
Hi Jordan

Mhm, I thought that content in the sidebars if connected would just give one result showing the entry with the ... smallest ID? But if not, then not being able to search everything makes sudden sense :)

I think people should be able to search for page names and titles, but if they can't, well, that is acceptable.

Thanks for the input.
Pritam replied on at Permalink Reply
I am using Concrete and was trying to implement the search block within my theme template as belows:
   $bt_search = BlockType::getByHandle('search');
   $bt_search->controller->title = 'Search';
   $bt_search->controller->buttonText = 'Go';
   $bt_search->controller->resultsURL = '/search-results';

As this was my first time with using the Search Block I referred to this documentation and did the steps mentioned, still could not get any search results.

Further digging I stumbled upon this thread and followed the steps mentioned, some of which were not mentioned in the old documentation relating to search, considering that it was published using the old concrete 5 version.

I visited the Dashboard >Sitemap >Page Search >Setup Index and choose Blacklist but did not check any items as i wanted to see search results showing up from everywhere, after doing this I also run the index job through System Maintenance but still the search results don't show up.

Can anyone help me on fixing this one.
cannonf700 replied on at Permalink Reply
1st, make sure you have THE search result page as a valid URL. your code is looking
or if you have pretty url's enabled then it would look like this: If this page doesn't exist then you won't get search results.

2nd, try using a custom template for the search block instead of hard coding it. That way the user can customize it and then apply your styling to it. I think this works better.