How to render search results in a specific area?

Permalink 1 user found helpful
The search block is located in another area!
synlag
View Replies:
synlag replied on at Permalink Reply 1 Attachment
synlag
In this tutorial, i show you how to create a single page from the search block.

Search results can appear at a single page within the view.php of the activated theme, also if the search block is located in another area.

Note: We assume <web-root> to be your public html directory, e.g.: /var/www/public_html. In concrete5 this corresponds to the variable BASE_URL in <web-root>/config/base.php.

1. Copy block 'search' from <web-root>/concrete5/blocks/search to <web-root>/blocks

~# cp -R <web-root>/concrete5/blocks/search <web-root>/blocks

2. Make directory <web-root>/blocks/search/templates/single_page_results

~# mkdir <web-root>/blocks/search/templates/single_page_results

3. Copy file <web-root>/blocks/search/view.php to <web-root>/blocks/search/templates/single_page_results/view.php

~# cp <web-root>/blocks/search/view.php <web-root>/blocks/search/templates/single_page_results/view.php

4. Create search.php once per directory <web-root>/single_pages and <web-root>/controllers.

~# touch <web-root>/single_pages/search.php
~# touch <web-root>/controllers/search.php

5. Afterwards, cut the php code at the bottom from <web-root/blocks/search/templates/single_page_results/view.php an paste it into <web-root>/single_pages/search.php.

6. Now, the single page still needs the controller code in the search block. At that create the class 'class SearchController extends Controller' <web-root>/controllers/search.php and copy the content of search blocks controller <web-root/blocks/search/controller.php into it.

8. Installation at Dashboard->Pages/Themes->Single Pages by entering 'search' and clicking on 'add to'.

9. When adding a search block choose 'search' as page target and template 'Single Page Results'.


All search results are now posted to the single page 'search and are rendered through $innerContent of the activated theme.

Files attached.