This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Customizing Settings Button Behavior

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Customizing Settings Button Behavior

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #46048
    GravKartanGravKartan
    Participant

    Hello! I’ll get straight to the point. I would like to add a CSS class to the settings button and ensure that it doesn’t open the settings but only has that custom CSS class. This is because the CSS class triggers the opening of a popup with the settings instead. The CSS class is: sok-installningar-1. Is it possible to achieve this? Thanks!

    #46066
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    Yes – it will involve a bit of custom coding, but via filter layouts templating you can modify the button layout file and add your custom CSS class.

    #46092
    GravKartanGravKartan
    Participant

    Hello,

    Thank you for the information! I attempted to implement the changes by following the knowledge base page you provided. I created a file at:
    /wp-content/themes/Avada/asp/filters/buttons/asp-button-filter.php

    I added the following code:

    php
    <?php foreach ($filter->get() as $button): ?>
        <div class="<?php echo $button->container_class; ?>">
            <button class="<?php echo $button->button_class; ?> sok-installningar-1"><?php echo esc_html($button->label); ?></button>
        </div>
    <?php endforeach; ?>

    Unfortunately, it doesn’t seem to be working. I suspect I might be doing something wrong. If you could assist me in identifying the issue, I would greatly appreciate it.

    #46097
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Oh, I’m sorry, I misinterpreted your query – that is not the button you want.

    The actual settings button in the search input can’t be changed via templating, but there is still hope.

    Try adding this code via the Code Snippets plugin or to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

    add_filter( 'asp_shortcode_output', 'asp_change_search_button_class', 10, 2 );
    function asp_change_search_button_class( $output, $id ) {
    	return str_replace("<div class='prosettings", "<div class='sok-installningar-" . $id . " prosettings", $output);
    }
    #46106
    GravKartanGravKartan
    Participant

    Hi! No worries. It seems it added “2_1” to the “sok-installningar-” class name, which is fine. I just changed the class name of the popup to “sok-installningar-2_1,” so now it works! Thank you very much for the support!

    There seems to be one problem now that I didn’t think of. Now when I press the settings button, it opens the popup as intended. However, once I open it again, it hides the settings, as the settings button usually does. Is there a way to prevent this?

    #46113
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Great!

    Yes, sort of a hacky way, but I think using a custom CSS to force visibility is the simplest way:

    .asp_ss {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    #46119
    GravKartanGravKartan
    Participant

    Hi! Awesome! It seems to be working, although it now affects all search bars. Is there a way to make it apply only to the search bar with the shortcode “[wd_asp id=2]” or something like that? I tried doing it with the ID of the search bar in a function but couldn’t get it to work. Any help is appreciated!

    #46128
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Great!

    Yes, of course, change it to:

    .asp_ss_2 {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    #46151
    GravKartanGravKartan
    Participant

    That seems to have done the trick! Thanks a lot!

    #46160
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

    #46175
    GravKartanGravKartan
    Participant

    For sure!

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Customizing Settings Button Behavior’ is closed to new replies.