Search Block

Permalink 2 users found helpful
Hi there C5 experts,

I am new in C5 and trying to make custom search block.

Here is my situation:

I have search form on top right area of my site thats global, and I want to have the result appear in the main(body) of my site.

Is this possible in C5?

Coz when I search for something the result appear next to it, and make my body area go downward, and when I use the "post to other page" I ended on two search block, 1 on the top right, and one on the body area.

Can anybody help me with this?


View Replies:
Mnkras replied on at Permalink Reply
if you are going to have the search block on every page, i would hardcode it into the theme, for example,

<form id="searchform" action="<?php $this->url('/search/search-results')?>" method="get">
<input name="search_paths[]" type="hidden" value="">
<input name="submit" type="submit" id="searchsubmit" value="">
<input name="query" type="text" id="s" class="s">
jordanlev replied on at Permalink Reply
The way this is generally done is with 2 search blocks -- one is like the one you already have in the header (which you should probably use Mnkras's technique for as it makes life a lot easier for both you and your site users).

The you create a "search results" page (just a normal page you add like any other page) and put another search block in the main content area of that page. That search block will automatically pick up any searches sent to it and display results.

Make sure your header search boxes are set to send people to that "search results" page (it's the path in the first line of Mnkras's example, for example '/search/search-results').
kingpangilinan replied on at Permalink Reply
Hi there,
Before anything else, Thanks for your respones.

Both your comment helps me to understand the form on C5, but does not solve my problem...

Coz When I search using the search form given by Mnkras, the result always appearing on other search block but in the same page,
in page that has no search block I got no results.

How can I redirect my site to the page where I wanted to appear the result when I am searching..

i.e. I want to be in
when I search on any of my page. Coz I setup the
body as a search block only. so that I only have the header, footer, and the body that contains the search result.

jordanlev replied on at Permalink Reply
If the search box in your header was just a block that you added normally, then you want to edit that block and check the box that says "Post to Another Page Elsewhere", then in the textbox that appears type in:

(NOTE that this assumes your site is running at the top-level of its domain name -- like "". If instead you are running in a subdirectory, like "", then you would enter "/my_concrete_site/search_results" instead).

If you used Mnkras's code, though, you want to change his first line to this:
<form id="searchform" action="<?php $this->url('/search_results')?>" method="get">

(and again, that assumes the site is at the top-level of the domain name -- change that path accordingly if you're in a subdirectory).
kingpangilinan replied on at Permalink Reply
Hi jordanlev,

I use the form and instead of the
first method:
action="<?php $this->url('/search-result')?>"

I used this one
second method:
action="<?php echo '/concrete2/index.php/search-result/'; ?>"

And the second one works for me...
I used second approach instead of using the php code, is there any side effect for using the method that I came up???

or I just missed something why I can't use the proper way that you teach me???


jordanlev replied on at Permalink Reply
They are both "proper", it just depends on how you want to manage the site.

The way you did it is easier to understand and easier to change if you want the search box on some pages but not others.

But the other way (that Mnkras showed, where you put that php code into your theme templates) makes the search box automatically appear on every page in the site without you having to add it, and nobody can accidentally remove it or change it.

(Note that you can still add it to every page in the site even doing it your way, by adding it to "Page Defaults" in the Dashboard -> Pages and Themes -> Page Types).

So you just have to decide which is best for you and the people who are managing the website.

kingpangilinan replied on at Permalink Reply
Now I know why the
<?php $this->url('/search-result'); ?>

Does not seems to work,

There is no "echo".... aha^^

Nways thanks to you...