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

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
RyanC
Forum Members
Forum Members
Posts: 97
Joined: Fri Aug 05, 2011 9:02 pm

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

Post 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?
Last edited by RyanC on Fri Feb 10, 2012 6:54 pm, edited 1 time in total.
RyanC
Forum Members
Forum Members
Posts: 97
Joined: Fri Aug 05, 2011 9:02 pm

Re: Search results: menu text instead of title text

Post 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"-->
RyanC
Forum Members
Forum Members
Posts: 97
Joined: Fri Aug 05, 2011 9:02 pm

Re: Search results: menu text instead of title text

Post by RyanC »

Could someone at least point me in the right direction? Is what I'm asking even possible?
RyanC
Forum Members
Forum Members
Posts: 97
Joined: Fri Aug 05, 2011 9:02 pm

Re: Search results: menu text instead of title text

Post by RyanC »

Anyone? Is this possible?
uniqu3

Re: Search results: menu text instead of title text

Post 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}
RyanC
Forum Members
Forum Members
Posts: 97
Joined: Fri Aug 05, 2011 9:02 pm

Re: Search results: menu text instead of title text

Post by RyanC »

Thanks for that info. I'll give it a try soon. :)
RyanC
Forum Members
Forum Members
Posts: 97
Joined: Fri Aug 05, 2011 9:02 pm

Re: Search results: menu text instead of title text

Post 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.
Last edited by RyanC on Fri Feb 10, 2012 6:55 pm, edited 1 time in total.
uniqu3

Re: Search results: menu text instead of title text

Post by uniqu3 »

uniqu3 wrote: Using in Searchresult tmeplate:
RyanC
Forum Members
Forum Members
Posts: 97
Joined: Fri Aug 05, 2011 9:02 pm

Re: Search results: menu text instead of title text

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

Return to “CMSMS Core”