Search function modifications

This is a FORK of the CMS Made Simple project and is not oficially supported in any way by the CMS Made Simple development team.
Locked
flyingbuttressman

Search function modifications

Post by flyingbuttressman »

I have been working with CMSMS MLE for a client, and I wanted multi-lingual functionality in the search module. While I was at it, I enabled it to display a snippet of the page's content in the appropriate language. While I'm only using two languages (English and Spanish) this example may be useful to someone else. With the example, you will need to find the appropriate place in the code and enter the changes.

I'm using the Search module (version 1.5)

action.dosearch.php
------------------------------------------------------------------------------------------------------------------------
line 81

$content =& $node->GetContent();
if (isset($content))
{
if($_GET['hl']=="es_MX")
{
$pageContent = $content->GetPropertyValue("content_es");
}
else
{
$pageContent = $content->GetPropertyValue("content_en");
}
$col->AddItem($content->Name(), $content->GetURL(), $pageContent, $result->fields['total_weight']);
}
------------------------------------------------------------------------------------------------------------------------
line 231 (close enough)

foreach( $results as $result )
{
$title = $result->title;
$txt = $result->urltxt;
$txt = strip_tags($txt);
$txt = substr($txt, 0, 300);
foreach( $words as $word )
{
$title = preg_replace('/('.$word.')/i', '$1', $title);
$txt = preg_replace('/('.$word.')/i', '$1', $txt);
}
$result->title = $title;
$result->urltxt = $txt;
$newresults[] = $result;
}

------------------------------------------------------------------------------------------------------------------------
Result Template:

{if ($parent_lang=="en")}{$searchresultsfor}{else}Resultados de búsqueda para{/if} "{$phrase}"
{if $itemcount > 0}

  {foreach from=$results item=entry}
  url}">{$entry->title}
  {$entry->urltxt}[...]

  url}">{$entry->url}

  Read more...
  {/foreach}


{$timetaken}: {$timetook}-->
{else}
  {$noresultsfound}
{/if}
------------------------------------------------------------------------------------------------------------------------

Tell me what you think!
Attachments
Picture 15.png
Picture 14.png
Last edited by flyingbuttressman on Wed Jan 21, 2009 8:05 pm, edited 1 time in total.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Search function modifications

Post by Rolf »

Hey, looks very good, flyingbuttressman!!  :D

But a changed file could be overwritten with an upgrade. You will lose the changes...
Perhaps you could suggest this as a future request at the Forge. [ http://dev.cmsmadesimple.org/ ]

Even though, very nice! Keep going  ;)

Rolf
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
alby

Re: Search function modifications

Post by alby »

flyingbuttressman wrote: I have been working with CMSMS MLE for a client, and I wanted multi-lingual functionality in the search module.
I had misunderstanding.
For changing labels use {..... lang=$lang} in your tag and/or use $mle_translation.key

Alby
Locked

Return to “[locked] CMSMS MLE fork”