Demonland31 Posted August 9, 2022 Posted August 9, 2022 Is there a way to change the Checked Default Search Option on the Front Page? Currently it is set to "Pages" which doesn't return any search results. On other pages the default is Topics or This Forum. On the Front Page I would like it to either Default to "Everywhere" or "Topics". Is there anyway to change this?
Solution Ehren Posted August 9, 2022 Solution Posted August 9, 2022 Hi @Demonland31 There's no built in setting to control this but if you have access to the HTML of the page, add the following to the top of your existing code. If you used the page builder instead, you'll need to create a JS file and assign it to the page via the page settings. <script> // Change default search filter document.querySelector(".cSearchFilter__menu [value='all']").checked = true; document.querySelector('.cSearchFilter__text').innerText = document.querySelector('.cSearchFilter__menu input:checked + .cSearchFilter__menuText').innerHTML; </script> Demonland31, SeNioR- and OptimusBain 1 2
Demonland31 Posted August 9, 2022 Author Posted August 9, 2022 24 minutes ago, Ehren said: Hi @Demonland31 There's no built in setting to control this but if you have access to the HTML of the page, add the following to the top of your existing code. If you used the page builder instead, you'll need to create a JS file and assign it to the page via the page settings. <script> // Change default search filter document.querySelector(".cSearchFilter__menu [value='all']").checked = true; document.querySelector('.cSearchFilter__text').innerText = document.querySelector('.cSearchFilter__menu input:checked + .cSearchFilter__menuText').innerHTML; </script> Hi Ehren, Appreciate the help. How do I assign the js file to the page via page settings? Where is the page settings? Cheers.
Demonland31 Posted August 9, 2022 Author Posted August 9, 2022 Anyone searches for the fix for this in the future. Here it is -
Ehren Posted August 9, 2022 Posted August 9, 2022 1 hour ago, Demonland31 said: Hi Ehren, Appreciate the help. How do I assign the js file to the page via page settings? Where is the page settings? Cheers. If you don't want to use the plugin, you can create the JS file at: /admin/?app=cms&module=pages&controller=templates Click the JS tab and create your new file. Paste in the code from my earlier post, but remove the first and last lines (the script tags) since they're not required. Next, visit your Page list at /admin/?app=cms&module=pages&controller=pages and click Edit next to your page. Under the Page Includes tab, select the JS file which you just created. 🙂 Demonland31 1
Demonland31 Posted August 9, 2022 Author Posted August 9, 2022 1 hour ago, Ehren said: If you don't want to use the plugin, you can create the JS file at: /admin/?app=cms&module=pages&controller=templates Click the JS tab and create your new file. Paste in the code from my earlier post, but remove the first and last lines (the script tags) since they're not required. Next, visit your Page list at /admin/?app=cms&module=pages&controller=pages and click Edit next to your page. Under the Page Includes tab, select the JS file which you just created. 🙂 Appreciate that @Ehren. That worked too and was very helpful. Is there any way so to make it so that all quick searches throughout the forum default to Everywhere? Personally I find it easier and more helpful to have Everywhere and then either the drop down can narrow down or once the search results come through you narrow your parameters. Ehren 1
Ehren Posted August 9, 2022 Posted August 9, 2022 43 minutes ago, Demonland31 said: Appreciate that @Ehren. That worked too and was very helpful. Is there any way so to make it so that all quick searches throughout the forum default to Everywhere? Personally I find it easier and more helpful to have Everywhere and then either the drop down can narrow down or once the search results come through you narrow your parameters. You can add the code to the bottom of your globalTemplate theme file (or to the Footer HTML area if you're using "Simple Theme Editing"). Demonland31 1
Demonland31 Posted August 9, 2022 Author Posted August 9, 2022 Thank you so much @Ehren. You've been most helpful. Ehren 1
Recommended Posts