Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted August 9, 20222 yr 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?
August 9, 20222 yr Solution 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>
August 9, 20222 yr Author 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.
August 9, 20222 yr 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. 🙂
August 9, 20222 yr Author 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.
August 9, 20222 yr 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").