Jump to content

Change Checked Default Search Option on Front Page


Go to solution Solved by Ehren,

Recommended Posts

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?

Link to comment
Share on other sites

  • 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>

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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. 🙂

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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").

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...