Share » Forums » Setup & design » How can I include search results in...

How can I include search results in an override template?

How can I include search results in an override template?

Thursday 25 May 2006 10:36:02 am - 4 replies

Author Message

Marcin Drozd

Friday 26 May 2006 1:32:43 am

Hi Espen

There is

{include name=Result
         uri='design:content/searchresult.tpl'
         search_result=$search_result}

in standard search.tpl
You should use <form action={'/content/search/'|ezurl} method="get"> and you can change (override) the searchresult.tpl or create new one (ex. my_searchresult.tpl) and include its: uri='design:content/my_searchresult.tpl'

http://ez-publish.pl

Espen R

Friday 26 May 2006 8:13:07 am

Thank you for your kind advise. But that's not what I want to do.

I want to include the full search template (or just the searchresults.tpl) in another spesific node override so that I can retain the place in the nav hierarchy and hence also retain the nav tree menu in the same state.

If I just point the search form at /content/search/ there will be a jump out of context for the user. And I don't want that.

A kind soul on #ezpublish pointed me in the direction of using ezhttp(var,get) to transport the search text through the node template, but still it will not work. It doesn't display any search results, but at least it echoes the search text now.

Maybe I am doing something wrong, or maybe there are limitations in what's possible to do. I don't know.

Further assistance is very appreciated.

Using v3.6.7 btw.

Marcin Drozd

Sunday 28 May 2006 8:39:57 am

Hi
Because you dont use /content/search action, you have empty search result.
There is $search_text in search.tpl but this variable is set in kernel/content/search.php

$searchText = '';
if ( $http->hasVariable( "SearchText" ) )
{
    $searchText = $http->variable( "SearchText" );
}

and

$tpl->setVariable( "search_text", $searchText );

You can use fetch function in your full node override template like:

{def $search=fetch( 'content', 'search',
                    hash( 'text',     ezhttp( 'SearchText', 'get' ) ) )}
{foreach $search.SearchResult as $matched_node}
    {$matched_node.name|wash} <br />
{/foreach}

more: http://ez.no/doc/ez_publish/technical_manual/3_7/reference/modules/content/fetch_functions/search

use hash( 'text', ezhttp( 'SearchText', 'get' ) ) instead of hash(text,$search_text)

http://ez-publish.pl

Espen R

Tuesday 30 May 2006 6:58:06 am

Thank you. I will try this.

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu