Getting rid of Search bar in Blog Archive -> results page
Permalink
I have a standalone Blog Archive page that lists archives like this:
When you click on a month, you go to a new page that has a Search block with the results of that query for the month/year.
It works great, except the search field is present at the top of the results page. This makes sense because it's a "Search" block... but doesn't make sense as a results page for month/year.
Is there any way to remove this besides setting the CSS to display:none?
Thanks!!
When you click on a month, you go to a new page that has a Search block with the results of that query for the month/year.
It works great, except the search field is present at the top of the results page. This makes sense because it's a "Search" block... but doesn't make sense as a results page for month/year.
Is there any way to remove this besides setting the CSS to display:none?
Thanks!!
![mikeyt55](/files/avatars/177425.jpg)
So you want the results to be displayed on a page without a search block?
Yes, all you need to do is create a custom template for the search block and remove the inputs. To do that, just do the following:
Copy the file /concrete/blocks/search/view.php into /blocks/search/templates/no_input.php.
This will create a custom template for the search block called "No input". If you want to name it something else just choose a different name for no_input.php.
At this point the template is still exactly the same as the standard search block so you need to make some modifications. Open up the no_input.php file and find where the input is created and remove that code. For me it starts on line 11 and goes to line 21. So the code I removed is:
After that save the no_input.php file, then go to the results page and go into edit mode. Click the search block and choose "Custom Template". In the list of templates available you should see "No Input". Select that and save and the search box should be gone.
You can create as many templates as you like this way and reuse them anywhere in the site you want. Custom templates are a really powerful feature of concrete5 and can really come in handy.
Hope that helps!
Copy the file /concrete/blocks/search/view.php into /blocks/search/templates/no_input.php.
This will create a custom template for the search block called "No input". If you want to name it something else just choose a different name for no_input.php.
At this point the template is still exactly the same as the standard search block so you need to make some modifications. Open up the no_input.php file and find where the input is created and remove that code. For me it starts on line 11 and goes to line 21. So the code I removed is:
<?php if(strlen($query)==0){ ?> <input name="search_paths[]" type="hidden" value="<?php echo htmlentities($baseSearchPath, ENT_COMPAT, APP_CHARSET) ?>" /> <?php } else if (is_array($_REQUEST['search_paths'])) { foreach($_REQUEST['search_paths'] as $search_path){ ?> <input name="search_paths[]" type="hidden" value="<?php echo htmlentities($search_path, ENT_COMPAT, APP_CHARSET) ?>" /> <?php } } ?> <input name="query" type="text" value="<?php echo htmlentities($query, ENT_COMPAT, APP_CHARSET)?>" class="ccm-search-block-text" /> <input name="submit" type="submit" value="<?php echo $buttonText?>" class="ccm-search-block-submit" />
After that save the no_input.php file, then go to the results page and go into edit mode. Click the search block and choose "Custom Template". In the list of templates available you should see "No Input". Select that and save and the search box should be gone.
You can create as many templates as you like this way and reuse them anywhere in the site you want. Custom templates are a really powerful feature of concrete5 and can really come in handy.
Hope that helps!
Check out this add-on by Johnthefish!!
http://www.concrete5.org/marketplace/addons/search-block-templates/...
http://www.concrete5.org/marketplace/addons/search-block-templates/...
Psshhh! Where's the fun in that?
lol, true enough!! It's a viable option though!! I generally get add-ons like these and take them apart to learn and expand on them...