Sunday, July 7, 2013

Joomla 2.5: overwrite com_search layout

As overwriting layout of any component, e.g. overwrite com_content blog layout, to customize layout of com_search, you may copy its original 2 files below:
/components/com_search/views/search/tmpl/default_form.php: display search box and search filters / conditions
/components/com_search/views/search/tmpl/default_results.php: display search results
to the html folder of your template:
/templates/your_template/html/com_search/search/default_form.php
/templates/your_template/html/com_search/search/default_results.php

Let do a sample, in which we only search in Articles and display every search result with an intro image of the article if any.

Below is an example for an article with intro image:


The following image is before this customization:

Here are the image after this customization:

To do this sample, we modify the file /modules/mod_search/tmpl/default.php of mod_search to search Articles only. Add the following line to this file:
<input type="hidden" name="areas[]" value="content" />
before line:
<input type="hidden" name="task" value="search" />

And download this file and unpack, then copy folder html/com_search to your template and plugins/search/content/content.php to joomla content search plugin.

Base on this post, you can create your search layout as you want.



No comments:

Post a Comment

Subscribe to RSS Feed Follow me on Twitter!