Page 1 of 1

Custom label text for search

Posted: Sat Dec 29, 2007 4:49 pm
by Fafek2
Hi,

I'm total newbie in CMS Made Simple and I am not keen PHP programmer, but I tried hack Search module and now I'm able to pass my own label text for the search field.

I added to Search.module.php two lines:

Code: Select all

$this->CreateParameter('labeltext', 'null', 'Label for search field');
	$this->SetParameterType('labeltext', CLEAN_STRING);
And slightly modified action.default.php file:

Code: Select all

$labeltext = (isset($params['labeltext'])) ? $params['labeltext'] : $this->Lang('search');
$this->smarty->assign('label', '<label for="'.$id.'searchinput">'.$labeltext.'</label>');
Total shock! It works!

Unfortunetly if post on my template something like this:

Code: Select all

{search labeltext='Search in <span class="site_title">My<span>service</span></span>
, tags are not parsed.
Is there any easy way to fix it?

Re: Custom label text for search

Posted: Sat Dec 29, 2007 5:08 pm
by RonnyK
What are you trying to achieve, search has several parameters, that can be passed

(optional) submit="Submit" - Text to place into the submit button
(optional) searchtext="null" - Text to place into the search box

The label in front is pulled out of the language-file of the "default frontend language" or the parameter "lang="xx_XX"" if that is given in the calling of search.

So to change the label, you could change the language-file, under Modules\Search\lang\ or you could code it in the Search template under "Extensions -> Search -> Search template".
{$startform}

{$label}: {$inputbox}
{if isset($hidden)}{$hidden}{/if}

{$endform}
Change the variable $label to a coded word that you want to see instead.

Ronny