Custom label text for search

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
Fafek2

Custom label text for search

Post 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?
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm
Location: Raalte, the Netherlands

Re: Custom label text for search

Post 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
Post Reply

Return to “Developers Discussion”