Replace search button by different texts to be searched

General questions about CMSimple
Post Reply
markus.leder
Posts: 9
Joined: Sun Sep 14, 2008 3:47 am

Replace search button by different texts to be searched

Post by markus.leder » Fri Apr 24, 2009 2:38 pm

Hi there,
I have a cookingrecipe page and have the recipes sorted by... fish, pork, beef, vegetarian....

Recently I added the option to find recipes by ingredient... tomato, potato etc...
(people go to a page where I added "all" links to recipes about certain ingredient)
the problem is that I add recipes constantly and many times forget to add the link on the "ingredient" page, it's also a lot more work :-)

I am trying now to replace the "search button" and "search field" by the "searchterm"... so visitors can directly click on a "ingredient link" and find all recipes containing the ingredient

How can I transform this into a "clickable link"?
<form action="/en/" method="post"><div id="searchbox"><input class="text" name="search" size="17" type="text"><input name="function" value="search" type="hidden"> <input class="submit" value="Search" type="submit"></div></form>

Example:
the link: potato ... will result in a search of all recipes that contain the word potato and therefore lead visitors to a list with "all" recipes.... this is much easyer than add hundrets of links by hand!!!!



Can you help me?

Tata
Posts: 3588
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Replace search button by different texts to be searched

Post by Tata » Fri Apr 24, 2009 8:43 pm

Try to replace the
function searchbox() {
with this code:

Code: Select all

function searchbox() {
	global $sn, $tx;
	return '
	<form action="'.$sn.'" method="post">
	<div id="searchbox">
	<select name="search" size="2">
	<option value="apples" SELECTED>apples</option>
	<option value="carrots">carrots</option>
	<option value="onion">onion</option>
	<option value="chilli">chilli</option>
	<option value="jalapenos">jalapenos</option>
	</select>
	'.tag('input type="hidden" name="function" value="search"').' 
	'.tag('input type="submit" class="submit" value="'.$tx['search']['button'].'"').'
	</div>
	</form>';
	}
It is not exactly what you mean, but seems to be wery close. I have not yet found how to use multiple choice. Maybe a simple plugin for easier administration would be worth.
****
Something like this: tata_search. It is very simple plugin. But for someone more skilled than myself it may be a starting idea for some more advanced plugin(multiple choice, some design if used on a page instead in the template...).
Try

Code: Select all

#cmsimple $output.=tata_search();#
on page or in template

Code: Select all

<?php echo tata_search()'?>
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

Martin
Posts: 346
Joined: Thu Oct 23, 2008 11:57 am
Contact:

Re: Replace search button by different texts to be searched

Post by Martin » Sun Apr 26, 2009 12:30 pm

Just add two parameters - &function=search (to call the search function) and &search=search_term (to define what to look for) - to your links.
Something like this

Code: Select all

http://www.your_site.com?your_recipe_index&function=search&search=potato
would e.g. return a list of all pages containing the word potato.

Post Reply