Is there any possibility to get in jfilters selections element also at least id of field container as class... like it's in filter module (jfilters-filter-container-"mod_id"-"filter_id"). Problem is that I have 3 integer fields, and would like to add at least some css:before pretext to number in selection.
Support
JFilters Selections - Filter category ID as class
Public
Closed
Latest post by sakinho on Wednesday, 12 July 2023 13:36 EEST
polovsek
sakinho
Hi
All the values in the selections module have the same class.
But if just want to add some text, why not adding that directly in the layout (using template overrides)?
Check the layout: modules/mod_jfilters_selections/tmpl/default.php
You can add that text based on a value's filter id.
To get the filter id, try this:
$filterId = $selectedOption->getParentFilter()->getId();
In the line 50
Kind regards,
Sakis Terzis
Founder and Lead Developer
polovsek
Works great. TNX.
polovsek
in the end I used this logic:
<?php
/** @var OptionInterface $selectedOption */
foreach ($selectedOptions as $selectedOption) {
$filterName = '';
$filterId = $selectedOption->getParentFilter()->getId();
if ($filterId == 6) {
$filterName = JText::_('COM_CONTENT_FIELDS_VOLUME');
} elseif ($filterId == 7) {
$filterName = JText::_('COM_CONTENT_FIELDS_ISSUE');
}
$uri = $filtersHelper->getUri($selectedOption);
?>
<?php echo $filterName . htmlspecialchars($selectedOption->getLabel()); ?>
<?php
}
?>
to call needed JText:: and it works even better if I would use css:before
<?php
/** @var OptionInterface $selectedOption */
foreach ($selectedOptions as $selectedOption) {
$filterName = '';
$filterId = $selectedOption->getParentFilter()->getId();
if ($filterId == 6) {
$filterName = JText::_('COM_CONTENT_FIELDS_VOLUME');
} elseif ($filterId == 7) {
$filterName = JText::_('COM_CONTENT_FIELDS_ISSUE');
}
$uri = $filtersHelper->getUri($selectedOption);
?>
<?php echo $filterName . htmlspecialchars($selectedOption->getLabel()); ?>
<?php
}
?>
to call needed JText:: and it works even better if I would use css:before
sakinho
Great!
I am closing the ticket as resolved.
Kind regards,
Sakis Terzis
Founder and Lead Developer