Page 1 of 1

[SOLVED]Search results: menu text instead of title text

Posted: Tue Jan 31, 2012 8:03 pm
by RyanC
http://forum.cmsmadesimple.org/viewtopi ... 28&t=53903

Hi I am having the same issue that was mentioned in the previous unanswered thread. How to have my search results be only the menu text, and not the title text?

Re: Search results: menu text instead of title text

Posted: Tue Jan 31, 2012 9:21 pm
by RyanC
This is the code I'm using:

Code: Select all

 {menu template="cssmenu.tpl"}
                        <div id="search">{search search_method="post" resultpage="search-results"}</div>
                           
		    </div><!--navbar-->
		</div><!--navContainer-->
            </div><!--navWrap-->
 
	  <div id="inner">
                    <div id="productInfo">
 
 <div id="searchResults">
{content block="searchResultsField"}

 
<div id="resultText">
<p>{$searchresultsfor} "{$phrase}"</p>
</div>
{if $itemcount > 0}
<ul>
  {foreach from=$results item=entry}
  <li><a href="{$entry->url}">{$entry->urltxt}</a> </li>
  
  {/foreach}
</ul>


{else}
  <p><strong>{$noresultsfound}</strong></p>
{/if}



</div><!--searchResults"-->

Re: Search results: menu text instead of title text

Posted: Wed Feb 01, 2012 4:23 pm
by RyanC
Could someone at least point me in the right direction? Is what I'm asking even possible?

Re: Search results: menu text instead of title text

Posted: Fri Feb 03, 2012 5:01 pm
by RyanC
Anyone? Is this possible?

Re: Search results: menu text instead of title text

Posted: Fri Feb 03, 2012 5:35 pm
by uniqu3
UDT:

Code: Select all

/** 
* @params string $params['url']
*/
$gCms = cmsms();
$cntnt = cmsms()->GetContentOperations();

foreach ($cntnt->GetAllContent() as $page) {
if ($page->GetURL() == $params['url']) {
   $return = ($page->menutext());
   //print_r($page);
   break;
}
}
if(!empty($params['assign'])){
        $smarty = cmsms()->GetSmarty();
        $smarty->assign(trim($params['assign']), $return);
}
else{
        return $return;
}
Using in Searchresult tmeplate:

Code: Select all

{udt_name_you_give url=$entry->url}

Re: Search results: menu text instead of title text

Posted: Fri Feb 03, 2012 9:12 pm
by RyanC
Thanks for that info. I'll give it a try soon. :)

Re: Search results: menu text instead of title text

Posted: Fri Feb 10, 2012 6:22 pm
by RyanC
Hi,
I created a UDT called "menu_as_results" with the code you supplied. Could you tell me where in the template to actually put that line? I don't know php yet so I don't understand where these tags belong.

Re: Search results: menu text instead of title text

Posted: Fri Feb 10, 2012 6:32 pm
by uniqu3
uniqu3 wrote: Using in Searchresult tmeplate:

Re: Search results: menu text instead of title text

Posted: Fri Feb 10, 2012 6:44 pm
by RyanC
I got it, thanks! :)

I fixed it, this was the place to put the code:

Code: Select all

 {foreach from=$results item=entry}
  <li><a href="{$entry->url}">{menu_as_results url=$entry->url}</a> </li>