Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

StackOverflow Point

StackOverflow Point Navigation

  • Web Stories
  • Badges
  • Tags
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Web Stories
  • Badges
  • Tags
Home/ Questions/Q 1948
Alex Hales
  • 0
Alex HalesTeacher
Asked: May 31, 20222022-05-31T08:36:55+00:00 2022-05-31T08:36:55+00:00

jquery – Customizing filters layout from joomla.searchtools.default for list view of custom component

  • 0

[ad_1]

In Joomla 4, there is the layout joomla.searchtools.default for the filters in a list view that you can see everywhere in the BackEnd.

In a list view of my custom component (FrontEnd), I managed to apply the layout joomla.searchtools.default for the filters. All is working fine.

Now I want to customize the layout. To avoid touching core files, I made a copy of the templates in the layout (joomla.searchtools.default) to my custom component. All is working fine.

Specifically, I want to get rid of the “filter options” button (which hides and shows the filters), but keep the useful “clear” button. This way, users will always see the filters.

There is a template called bar.php where you can see the following code:

<div class="filter-search-actions btn-group">
    <?php if ($filterButton) : ?>
        <button type="button" class="filter-search-actions__button btn btn-primary js-stools-btn-filter">
            <?php echo Text::_('JFILTER_OPTIONS'); ?>
            <span class="icon-angle-down" aria-hidden="true"></span>
        </button>
    <?php endif; ?>
    <button type="button" class="filter-search-actions__button btn btn-primary js-stools-btn-clear">
        <?php echo Text::_('JSEARCH_FILTER_CLEAR'); ?>
    </button>
</div>

In the code snippet, you can see two buttons: JFILTER_OPTIONS and JSEARCH_FILTER_CLEAR

There is other template called filters.php that really displays the filters:

<?php if ($filters) : ?>
    <?php foreach ($filters as $fieldName => $field) : ?>
        <?php if ($fieldName !== 'filter_search') : ?>
            <?php $dataShowOn = ''; ?>
            <?php if ($field->showon) : ?>
                <?php $wa->useScript('showon'); ?>
                <?php $dataShowOn = " data-showon='" . json_encode(FormHelper::parseShowOnConditions($field->showon, $field->formControl, $field->group)) . "'"; ?>
            <?php endif; ?>
            <div class="js-stools-field-filter"<?php echo $dataShowOn; ?>>
                <span class="visually-hidden"><?php echo $field->label; ?></span>
                <?php echo $field->input; ?>
            </div>
        <?php endif; ?>
    <?php endforeach; ?>
<?php endif; ?>

How could I get rid of the JFILTER_OPTIONS button (without losing the visibility of the filters) and maintain the functionality of the JSEARCH_FILTER_CLEAR button?

All is related with the js-stools-container-filters class in the divs’ containers, I suppose, but I can’t find more information.

Code snippet in the default_filter.php template (the “main” template):

// Load search tools
HTMLHelper::_('searchtools.form', $data['options']['formSelector'], $data['options']);
?>
<div class="js-stools" role="search">
    <?php if ($data['options']['showSelector']) : ?>
    <div class="js-stools-container-selector">
        <?php echo $this->sublayout('selector', $data); ?>
    </div>
    <?php endif; ?>
    <div class="js-stools-container-bar">
        <div class="btn-toolbar">
            <?php echo $this->sublayout('bar', $data); ?>
            <?php echo $this->sublayout('list', $data); ?>
        </div>
    </div>
    <!-- Filters div -->
    <div class="js-stools-container-filters clearfix<?php echo $filtersActiveClass; ?>">
        <?php if ($data['options']['filterButton']) : ?>
        <?php echo $this->sublayout('filters', $data); ?>
        <?php endif; ?>
    </div>
</div>
<?php if ($data['options']['showNoResults']) : ?>
    <?php echo $this->sublayout('noitems', $data); ?>
<?php endif; ?>

[ad_2]

  • 0 0 Answers
  • 11 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Related Questions

  • xcode - Can you build dynamic libraries for iOS and ...

    • 0 Answers
  • bash - How to check if a process id (PID) ...

    • 4775 Answers
  • database - Oracle: Changing VARCHAR2 column to CLOB

    • 1063 Answers
  • What's the difference between HEAD, working tree and index, in ...

    • 1009 Answers
  • Amazon EC2 Free tier - how many instances can I ...

    • 0 Answers

Stats

  • Questions : 43k

Subscribe

Login

Forgot Password?

Footer

Follow

© 2022 Stackoverflow Point. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.