-
-
Notifications
You must be signed in to change notification settings - Fork 214
Integrate a Hook to customize searched Pages in \ModuleSearch #5223
Comments
@contao/workgroup-core |
Sorry, but that does not make sense. That is a custom extension case. Check out https://github.com/aschempp/contao-rootsearch for a hint. The module might be outdated, not sure if it works in your installation. |
@aschempp Yes it is a case for an extension, but i need the hook, otherwhise i can't manipulate the data |
Well you need to add the sites anyway, not? The search module is only a front end to the search engine library class, every custom frontend module can use the search engine class. |
The Sites are in the Index, but they are from another Page-Root, so the \ModuleSearch would automatically only include all the Sites of the currently visited Root-Page. To make it search across all my Root-Pages i have to add the Sites here. |
Have you checked out my extension? It does exactly what you need (search over multiple root sites)... |
** I've to correct my statement from above, that it should be in an own extension, i mean only "mini-extension" giving the Sites I wan't to be searched to the \ModuleSearch, so I dont't have to rewrite the whole module (as you did in Root-Search). i only add my Sites in a Hook and the Module takes all the Sites I want to have searched into account So my "Root-Search" would only add all Site-ID's in the \ModuleSearch I'll upload my code later, I have already integrated this in a project |
Ok. So if we are going to do something, we should change the module so that the individual functionalities are in separate methods, and your new extension can simply override them. @leofeyer what do you think? Want a pull request? |
That would be best case, so I've got a method to override, which only populates the sites-id data. |
@leofeyer what is your opinion? |
In my locally integrated HOOK i just use the following code to implement a Search-Module, which is taking all Sites into account. <?php
class EnhancedSearch extends \Controller
{
public function customizeSearch($arrPages)
{
// Modify the Pages
$allPages = \Database::getInstance()->prepare('SELECT `id` from tl_page where pid != 0')->execute();
while($allPages->next())
$arrPages[] = $allPages->id;
array_unique($arrPages);
return $arrPages;
}
} |
Would #6792 also solve this issue? |
Implemented in e77d3fa. |
shouldnt there be a return value? |
By reference? http://php.net/manual/en/language.references.pass.php |
Hello,
Problem:
you can not modify the searched Pages from \ModuleSearch
Solution:
as you can see in https://gist.github.com/4482409/5e7273acc3fdec713cd256797075a82987776b94#file-gistfile1-php-L125 i have added a Hook in the /system/modules/core/modules/ModuleSearch.php in order to customize the pages searched in the module.
Maybe a Hook-Name like 'getSearchedPages' or something like that would be better.
Zusätzlich:
Why?
I have a multidomain project, where i want to enable the search over all of my root-pages.
If this Hook is integrated I'm able to develop a CrossSiteSearchModule.
The text was updated successfully, but these errors were encountered: