Code search box into theme?

Permalink 1 user found helpful
Hello all

I'm trying to put a search box on every page of my site, via hard-coding into the theme rather than using blocks (I don't want editors to have to manually add the search box).

I can't find out how to do this - I can find what to do after the search box is there, but not the code to insert the d*mn thing.

I think c5 could do with a tutorial on how to hardcode blocks into themes, as this is a problem I've come across several times! Abstracting the design from the content is good from the point of view of reducing the risk that editors will screw things up or forget to add blocks where necessary!

melat0nin
 
synlag replied on at Permalink Reply
synlag
take a look at the installation routine for the sample content and there it is :)
All you have to do is disabling editing for the block.
melat0nin replied on at Permalink Reply
melat0nin
Can you be more specific please? I was looking at view.php but i'm convinced that's what you mean..
synlag replied on at Permalink Reply
synlag
Ok.

In the installation routine file for the sample content, when doing a fresh installation, you can see how blocks are assigned to all type of pages (just as a side note).

Add the search block to your area and disable editing for this area.

$area->disableControls;
$area->display($c);


Another solution could be to enable advanced permission and remove all allowed groups, to only give admin (superuser) access.
ryan replied on at Permalink Best Answer Reply
ryan
Here's some simple html that'll work.
Just make sure you put a search block on the page /search then this form essentially posts to that page with the query variable.

<div id="search-box">
<form action="<?php echo View::url('search'); ?>">
   <input type="text" id="search-keywords" name="query" value="Search" />
   <input type="submit" id="search-go" name="go" value="go"/>
</form>
</div>
synlag replied on at Permalink Reply
synlag
Cool, not thought about that, thx.

Would that work for external form block too?

Instead of using search url, form blocks..., testing
melat0nin replied on at Permalink Reply
melat0nin
Thanks very much, that worked great :)
Abs0lute replied on at Permalink Reply
Abs0lute
Exactly what I needed. Thanks Ryan, you're the man!
bshea replied on at Permalink Reply
ryan, I might be a little new to this but can't get this to work. My "search" page is located as a child page to "contact". I think I change this to;

<div id="search-box">
<form action="<?php echo View::url('contact/search'); ?>">
<input type="text" id="search-keywords" name="query" value="Search" />
<input type="submit" id="search-go" name="go" value="go"/>
</form>
</div>

I guess the other question is can I just add a block with html and cut and paste this into that edit html window.

Site is thirdstreetflats.com if it helps.

Much thanks in advance.
Bshea
sebastienj replied on at Permalink Reply
sebastienj
Really great !