Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › How to turn off for mobile but then use built in search
- This topic has 7 replies, 2 voices, and was last updated 10 years, 1 month ago by
Ernest Marcinko.
-
AuthorPosts
-
April 26, 2016 at 12:18 am #8484
imagefact
ParticipantHi,
On a site I’m building I’d like to have AjaxSearchPro for desktop, but hide it for mobile where I’d like to replace it with the built in search widget.
I see there’s a button to disable for mobile, but this doesn’t all the regular widget to then be active.
I was planning on Hiding (display:none) your searchbox — but the problem is it is still disengaging the built in search….
SO. How to do this?
– OR –
Can I use your search field to type in a request, but then have it just jump to the built in search WITHOUT popping up the the inbetwen results lightbox… The reason overall is the your plugin, while nice, is very clunky on mobile, so I need to send users to a full screen results page.
Thanks in advance. I see you’ve done a huge amount of work on this plugin and it shows.
April 26, 2016 at 9:38 am #8490Ernest Marcinko
KeymasterHi!
Indeed, that option is not working correctly, it should display the default engine if it’s checked. I’m planning to extend that options page, whit more settings.
I think the best solution would be to suggest you a temporary fix for the issue with the theme search replacement. Open up the wp-content\plugins\ajax-search-pro\includes\classes\filters\class-asp-formoverride.php file, it’s a small file, and replace this code:
[php]function handle( $form = "" ) {
$asp_st_override = get_option("asp_st_override", -1);if ( $asp_st_override > -1 && wd_asp()->instances->exists( $asp_st_override ) )
return do_shortcode("[wpdreams_ajaxsearchpro id=".$asp_st_override."]");return $form;
}[/php]with this code:
[php]function handle( $form = "" ) {
$asp_st_override = get_option("asp_st_override", -1);if ( $asp_st_override > -1 && wd_asp()->instances->exists( $asp_st_override ) ) {
$new_form = do_shortcode("[wpdreams_ajaxsearchpro id=".$asp_st_override."]");
if ( strlen($new_form) != 0 )
return $new_form;
else
return $form;
}return $form;
}[/php]I hope it works.
April 26, 2016 at 4:18 pm #8497imagefact
ParticipantHi Ernest,
Thank you for getting back to me so quickly. I had no trouble replacing the code (I do some PHP myself so I’m familiar), unfortunately it isn’t doing anything. No difference from the original… ?
I double and triple checked it’s there, and settings.
Just to check with you, after replacing code, the setting to change in the panel is:
General Options > Mobile Behavior > Display the search bar on mobile devices? [OFF]Correct? Anything else I’m supposed to be doing so the desktop is your plugin, mobile is built in search?
April 27, 2016 at 11:13 am #8507Ernest Marcinko
KeymasterHi!
Make sure to clear your cache (CDN, page cache, browser cache etc..), the changes might be affected by that.
It works on my test environment, but of course I’m not sure if this is correct with every configuration. If it’s not caching, can you provide temporary back-end and FTP details so I can debug the code?
April 28, 2016 at 2:14 pm #8527imagefact
ParticipantHi Ernest,
Thank you. None of those apply, so it’s something else. I’ll set up a testing ground since the site in question is in constant flux as I program it… I’ll follow up soon (Thank you for your follow ups!).
April 28, 2016 at 3:34 pm #8531Ernest Marcinko
KeymasterThank you for that! In the meantime I did further tests on this issue, but I still didn’t find anything unfortunately. I suspect it might be relevant to a certain configuration. We will definitely find out 🙂
April 29, 2016 at 7:08 am #8540imagefact
ParticipantOk, mystery solved!
Your code worked. I was expecting it to act like a media query, so I was shrinking my browser and expecting your plugin to disappear below 768px or so. But it doesn’t.
Now I know, it checks for mobile differently. So yes, True mobile now shows the built in search widget, while True desktop only shows ASP (your plugin).
I THINK this will be ok. I’ll have to see the different ramifications of not having granular media query control. But for now we’ll call this done, and I look forward to the fix in the next release so I don’t have to patch each upgrade.
I thank you very much for your terrific support. I actually have a few other (smaller) points to ask about which I’ll put in a fresh thread. THANK YOU!
April 30, 2016 at 9:16 am #8547Ernest Marcinko
KeymasterGreat! I’m glad to hear it’s working now.
Yes, it checks for mobile based on the browser type and other properties on the server side, so the plugin is not printed at all when viewing the page, saving a tiny bit of bandwith 🙂
I will close this thread now and mark it as resolved then.
-
AuthorPosts
- The topic ‘How to turn off for mobile but then use built in search’ is closed to new replies.