I think I have stumbled on an issue with the search filter displayed in the Contacts listing for a specific category. I'm relatively new to this so please forgive any mistakes.
J!3.0.2
When a menu item created for listing contacts of a specific category, the Search input box was displayed. I wasn't able to find the switch to hide this and any input was ignored as far as filtering was concerned.
default_items.php view had the following line of code
params->get('filter_field') != 'hide') :?>There was no parameter "filter_field" in the xml files (default.xml or config.xml).
Insert following into admin/config.xml at around line 433
<field name="filter_field" type="radio"
default="1"
class="btn-group"
label="COM_CONTACT_FIELD_FILTER_FIELD_LABEL"
description="COM_CONTACT_FIELD_FILTER_FIELD_DESC"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
Insert following into site/views/category/tmpl/default.xml at around line 95
<field name="filter_field" type="list"
label="COM_CONTACT_FIELD_FILTER_FIELD_LABEL"
description="COM_CONTACT_FIELD_FILTER_FIELD_DESC" >
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
To maintain the standard for these switches with values of 0 or 1 the following needs to be amended in site/views/category/tmpl/default_items.php line 22
from params->get('filter_field') != 'hide') :?>
to params->get('filter_field') != 0) :?>
insert the buttons to execute the search and clear the search at line 26
<button class="btn hasTooltip" type="submit" title="<?php echo JText::_('JSEARCH_FILTER_SUBMIT'); ?>"><i class="icon-search"></i></button>
<button class="btn hasTooltip" type="button" title="<?php echo JText::_('JSEARCH_FILTER_CLEAR'); ?>" onclick="document.id('filter-search').value='';this.form.submit();"><i class="icon-remove"></i></button>
Insert some help language text to admin/language/en-GB/en-GB.com_contact.ini
COM_CONTACT_FIELD_FILTER_FIELD_DESC="Show or hide the search filter input box"
COM_CONTACT_FIELD_FILTER_FIELD_LABEL="Display Search Filter"
And update the model to perform the search
Insert around line 168 in the getListQuery function
// Filter by search input
$search = $this->getState('filter.search');
if (!empty($search)) {
$search = $db->Quote('%'.$db->escape($search, true).'%');
$query->where('( a.name LIKE '.$search.' )');
}
Insert around 256 in the populateState function
// Load the filter state.
$search = $app->getUserStateFromRequest('filter.search', 'filter-search');
$this->setState('filter.search', $search);
If I have missed something or mis-understood where this search execution is performed, I apologise. Cheers.
Glenn
Hi Nick,
Will do, just going through the doco link you sent me... It's time I learned about GitHub, so thanks for the push. It may take me a wee while though. Cheers.
Glenn
Cheers Glenn! :) If you need any help, send us a message on the JCMS mailinglist:
https://groups.google.com/forum/?fromgroups#!forum/joomla-dev-cms
Hi Nick,
Just went through the suggested changes and it appears that someone else has made changes (better than mine) suitable to make the process work as it should. I just downloaded the master and ran a test on a fresh install and all is good. So this issue can be closed IMO. Cheers.
Awesome; glad to hear that Glenn! :)
Cheers
Labels |
Added:
?
Removed: ? |
||
Build | ⇒ | staging |
Hi and welcome, Garkell! :)
Thanks for posting this! Can you send a pull request so that others can test? If you need to learn how, check out this tutorial:
http://docs.joomla.org/Git_for_Coders