Create searchable block
Permalink
I've built a few blocks in the meanwhile and some of them contain content that users should find.
Meaning lucene should index that stuff too.
Problem is however, there's this code that limits everything to the content block in indexed_search.php
I guess it should be quite easy to add a bit more flexibility to this.
Using an interface ISearchable that a block could implement or adding a method getSearchableContent and check if the block implements this method or or...
Meaning lucene should index that stuff too.
Problem is however, there's this code that limits everything to the content block in indexed_search.php
if ($b->getBlockTypeHandle() == 'content') { $bi = $b->getInstance(); $text .= strip_tags($bi->content); }
I guess it should be quite easy to add a bit more flexibility to this.
Using an interface ISearchable that a block could implement or adding a method getSearchableContent and check if the block implements this method or or...
This thread is a bit old, but I just want to agree wholeheartedly that custom block types should have some way to make appropriate content searchable. Does anyone know if this idea has been picked up by the core team?
they do now i believe
Yeah, this thread is quite a bit old. We don't use the lucene indexer anymore. And blocks can specify how to make their content searchable. Simply add a function named getSearchableContent() in your block's controller, and return plain text from it. This will be included in the search index for the page.
Ok, that makes perfect sense -- Thanks, Andrew!!
No problem!
One more thing: in 5.4.0 we introduced a concept of searchable areas that you can define through the dashboard. Basically you tell the site which areas contain blocks that you want to make searchable (so you don't have left nav, etc... header nav, etc... contain searchable content.) This is just another way to have control. However, there's a bug in 5.4.0 that may make it so that your setup is only allow areas that have been specifically whitelisted to be searched - with no areas actually whitelisted! That's a bummer (and something we're fixing) but you may want to check out Dashboard > Sitemap > Page Search > Setup Index, if you think it's happening to you.
One more thing: in 5.4.0 we introduced a concept of searchable areas that you can define through the dashboard. Basically you tell the site which areas contain blocks that you want to make searchable (so you don't have left nav, etc... header nav, etc... contain searchable content.) This is just another way to have control. However, there's a bug in 5.4.0 that may make it so that your setup is only allow areas that have been specifically whitelisted to be searched - with no areas actually whitelisted! That's a bummer (and something we're fixing) but you may want to check out Dashboard > Sitemap > Page Search > Setup Index, if you think it's happening to you.
And how do I "return plain text from it?"
I'm trying to make the Tags searchable. Currently, you can click any tag and it will spit out all the articles on the Search-Results page.
BUT, try to search for that same tag in a Search Box. You get bupkiss.
Can you please explain the code I would need to add to the Tags controller a bit more thoroughly than "add getSearchableContent() and return plain text from it?" I don't even think this will work, anyway, for my problem. Search-Results would probably just spit back a tag block rather than the articles tagged.
I'm trying to make the Tags searchable. Currently, you can click any tag and it will spit out all the articles on the Search-Results page.
BUT, try to search for that same tag in a Search Box. You get bupkiss.
Can you please explain the code I would need to add to the Tags controller a bit more thoroughly than "add getSearchableContent() and return plain text from it?" I don't even think this will work, anyway, for my problem. Search-Results would probably just spit back a tag block rather than the articles tagged.