User tests: Successful: Unsuccessful:
Bring up all relevant filters to the modal category field.
The template code is simplified while enjoying the factorization of JLayoutHelper.
To test the modal category field ( you can do what is indicated at #8185; listed below ) :
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
Title |
|
I have tested this item successfully on b5cf4b8
Test OK
Status | Pending | ⇒ | Ready to Commit |
Setting RTC - thanks for testing
Labels |
Added:
?
|
I am taking off the RTC Label here as this patch has the potential of killing multilingual sites category associations by letting associate a category to itself or to the wrong target language. The language filter/Select should NOT display in this case. It should obey to ForcedLanguage
See this screen capture:
https://www.dropbox.com/s/ij46tywkgvpwtu6/modal_categories.mp4?dl=0
Status | Ready to Commit | ⇒ | Pending |
Taking off RTC
Labels |
Removed:
?
|
Can you have a look at this? I tried to play with filtersHidden without much success.
I have a solution which works here, by not displaying the language filter in SearchTools ONLY when dealing with category multilingual associations.
It introduces though a change in /layouts/joomla/searchtools/default/filters.php
This "may" not be an issue as we could use it in the other modals when forcedLanguage is used for associations.
We first have to check if the modal_category type field is used when dealing with category associations. The variable $function
in this case contains jSelectCategory_jform_associations_xx_XX
where xx_XX is en_GB, fr_FR, etc.
In /administrator/components/com_categories/views/categories/tmpl/modal.php (once applied this PR), I add on top
// Are we dealing with category associations?
$forcedLanguage = strpos($function, 'associations') !== false ? true : false ;
Then I modify further down the call to searchtools layout by adding an option:
<?php if ($this->state->get('filter.forcedLanguage') && $forcedLanguage == true) : ?>
<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this, 'options' => array('language' => 'forcedlanguage'))); ?>
<?php else : ?>
<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
<?php endif; ?>
Then I modify /layouts/joomla/searchtools/default/filters.php to get something like:
<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_BASE') or die;
$data = $displayData;
// Load the form filters
$filters = $data['view']->filterForm->getGroup('filter');
// Check for forcedlanguage in multilingual associations
$forcedLanguage = in_array('forcedlanguage', $data['options']) ? true : false ;
?>
<?php if ($filters) : ?>
<?php foreach ($filters as $fieldName => $field) : ?>
<?php if ($forcedLanguage == true) : ?>
<?php if ($fieldName != 'filter_search' && $fieldName != 'filter_language') : ?>
<div class="js-stools-field-filter">
<?php echo $field->input; ?>
</div>
<?php endif; ?>
<?php else : ?>
<?php if ($fieldName != 'filter_search') : ?>
<div class="js-stools-field-filter">
<?php echo $field->input; ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
Here are the screenshots obtained.
First when associating categories, no more Language filter:
Then, after changing the catid field in article.xml to "modal_category"
@Bakual @phproberto
What do you think? Any better way?
Hmm, even that does not work perfectly when the field modal_category is added to other xmls.
'filtersHidden' is a boolean. I guess it is used to hide all filters ?
I propose to introduce a 'hiddenFilters' (array) option that lets us set filters as hidden:
/layouts/joomla/searchtools/default/filters.php
<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_BASE') or die;
$data = $displayData;
// Load the form filters
$filters = $data['view']->filterForm->getGroup('filter');
// Introduced a 'hiddenFilters' (array) option that lets us set filters as hidden
if (isset($data['options']['hiddenFilters']))
{
foreach ($data['options']['hiddenFilters'] as $hiddenFilter){
if (isset($filters[$hiddenFilter]))
{
unset($filters[$hiddenFilter]);
}
}
}
// Remove explicitly the search filter
unset($filters['filter_search']);
?>
<?php if ($filters) : ?>
<?php foreach ($filters as $fieldName => $field) : ?>
<div class="js-stools-field-filter">
<?php echo $field->input; ?>
</div>
<?php endforeach; ?>
<?php endif; ?>
Then, We can do:
echo JLayoutHelper::render('joomla.searchtools.default', array(
'view' => $this,
'options' => array(
'hiddenFilters' => array('filter_language')
)
));
This does not work either in categories association. When using the Clear button it reinstate the language filter.
FYI, this modal and the "modal_category" field were never coded to be used elsewhere than for category associations...
If someone wants to use that field elsewhere it should never show the language filter in the associations case and always display it in any other case. It has to be tested on a multilingual site and the "modal_category" field should be able to replace everywhere the "categoryedit" field.
I Thank You for your help,
I'll open an other PR "Possibility to remove filters individually when using the searchtools layout helper" with the code I have just given. I am convinced it could be useful in many situations.
If it's validated,
Here, It would allow to use the 'searchtools layout helper' (removing unwanted filters) in the 'modal_category' template . It will be a first step...
Ok for the new feature for the filters.php, but please remember that in this precise case of "modal_category", with your code (this PR + your proposed filters.php), we still have an issue with the Clear button when we have a conditional.
I am using this in the modal.php (after applying your PR)
// Are we dealing with category associations?
$forcedLanguage = strpos($function, 'associations') !== false ? true : false ;
?>
<form action="<?php echo JRoute::_('index.php?option=com_categories&view=categories&layout=modal&tmpl=component&function=' . $function . '&' . JSession::getFormToken() . '=1'); ?>" method="post" name="adminForm" id="adminForm">
<fieldset class="filter clearfix">
<?php if ($this->state->get('filter.forcedLanguage') && $forcedLanguage == true) : ?>
<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this, 'options' => array('hiddenFilters' => array('filter_language')))); ?>
<?php else : ?>
<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
<?php endif; ?>
<hr class="hr-condensed" />
</fieldset>
etc.
and I get
https://www.dropbox.com/s/qyi6j8pds5yrga4/cat_modal2.mp4?dl=0
If I do not have any conditional, then your filters.php works great.
Thank You,
You've pinpointed the problem : I had neglected 'forcedLanguage'.
There seems to work well with :
<fieldset class="filter clearfix">
<?php if ($this->state->get('filter.forcedLanguage')) : ?>
<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this, 'options' => array('hiddenFilters' => array('filter_language')))); ?>
<input type="hidden" name="forcedLanguage" value="<?php echo $this->escape($this->state->get('filter.forcedLanguage')); ?>" />
<input type="hidden" name="filter_language" value="<?php echo $this->escape($this->state->get('filter.language')); ?>" />
<?php else : ?>
<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
<?php endif; ?>
<hr class="hr-condensed" />
For issue 2, looks like it can be solved by re-adding
<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
``
in your PR
as for the tip we are already missing in the present modal.php the "data-placement="bottom"
For fix the issue 1. 'we can't sort anymore when clicking on the column headings'.
Every occurrence (4) of JHtml::_('grid.sort'
should be replaced with JHtml::_('searchtools.sort'
.
For fix issue 2. 'the Search Tools buttons tips are unreadable as they are displayed on top of the buttons':
JHtml::_('bootstrap.tooltip');
should be replaced with:
JHtml::_('bootstrap.tooltip','.hasTooltip', array('placement' => 'bottom'));
(Notice that bootstrap 2 does not allow 'auto top' placement)
@infograf768, thank you again
These would work indeed.
One side aspect (but not very important), now all tooltips are displayed at bottom, not only the buttons.
If you can give the searchtools buttons a specific class, then you can place those tooltips different from the others by using two JHtml::_('bootstrap.tooltip) calls. One generic and one for the search tool specific ones.
@Bakual
This PR, once modified and once #8767 is merged, uses the top buttons which are defined in the core layouts bar.php
We could override this layout when using com_categories directly, but would it work when the modal_category field is used in other contexts (for example a module or a menu item)?
We could override this layout when using com_categories directly, but would it work when the modal_category field is used in other contexts (for example a module or a menu item)?
We could also directly add a second class to the core JLayout for Searchtools, which would then allow to target it. Or maybe adjust the JLayout so a class could be passed.
Category | ⇒ | Layout |
if i understand correctly the issue here, this is already solved in latest staging @brianteeman @infograf768
Status | Pending | ⇒ | Information Required |
I am closing this at this time as it appears to have been resolved elsewhere and there has been no response to the comments. It can always be reopened if that is done.
Status | Information Required | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-06-07 09:59:25 |
Closed_By | ⇒ | brianteeman |
I have tested this item successfully on b5cf4b8
Works as expected.
Maybe you have to doublecheck how the select/deselect buttons and modal look on mobile devices.
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8633.