I've been trying to make this work so I can display few lines from the content in the search results. I found this old post with a great answer, but it is not working for cmsms 2.x. It seems to be exactly what I need.
I've been trying to rewrite the answer for cmsms 2.x but with out any luck. I believe I need more experience to be able to rewrite it so it works.
here is a UDT that have to be made (called 'set_alias')
Code: Select all
/** Get page alias from title
* @params string $params['title']
*/
$gCms = cmsms();
$cntnt = cmsms()->GetContentOperations();
foreach ($cntnt->GetAllContent() as $page) {
if ($page->mName == $params['title']) {
$return = ($page->mAlias);
break;
}
}
if(!empty($params['assign'])){
$smarty = cmsms()->GetSmarty();
$smarty->assign(trim($params['assign']), $return);
}
else{
return $return;
}
Here is the code for the search template
Code: Select all
<h3>{$searchresultsfor} "{$phrase}"</h3>
{if $itemcount > 0}
<ul>
{foreach from=$results item=entry}
{set_alias title=$entry->title assign='get_alias'} {* call set_alias udt and assign as get_alias *}
<li>{$entry->title} - <a href="{$entry->url}">{$entry->urltxt}</a> ({$entry->weight}%)<br />
{$cgsimple->get_page_content($get_alias,'content_en','result_content')}{$result_content|truncate:'160'|strip_tags} {* cgsimplesmarty looks through our var get_alias and content and assigns var result_content, then we output found content with result_content and truncate it to desired number of character *}
</li>
{/foreach}
</ul>
<p>{$timetaken}: {$timetook}</p>
{else}
<p><strong>{$noresultsfound}</strong></p>
{/if}
Can anyone help me to make this work for CMSMS 2.x?
here is a link to the old post
viewtopic.php?f=7&t=54145
the answer is from a user called uniqu3, maybe he is still active and sees this