Forums / Setup & design / How can I include search results in an override template?

How can I include search results in an override template?

Author Message

Espen R

Thursday 25 May 2006 10:36:02 am

I want to display the search results from a searchbox on the same page. This page has a full node override template.

So I thought I could just include a copy of search.tpl (which I placed in the templates folder of my siteview) in the override template for that node:

{include uri='design:search.tpl'}

and then set the action attribute of the search form (on the same page) to point to the url of the same page instead of '/content/search/'.

<form action={$node.url_alias|ezurl} method="get">

But it doesn't work. It does display the included template, but with no sesults. Seems like it cant's pick up the search text variable.

What's the correct way of doing this?

Help would be very appreciated.

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.

eZ debug

Timing: Jan 18 2025 14:56:12
Script start
Timing: Jan 18 2025 14:56:12
Module start 'content'
Timing: Jan 18 2025 14:56:14
Module end 'content'
Timing: Jan 18 2025 14:56:14
Script end

Main resources:

Total runtime1.6503 sec
Peak memory usage4,096.0000 KB
Database Queries200

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0062 589.0859180.7969
Module start 'content' 0.00621.5053 769.8828567.9922
Module end 'content' 1.51150.1387 1,337.8750337.3359
Script end 1.6502  1,675.2109 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.2452210.0002
Check MTime0.00140.0870210.0001
Mysql Total
Database connection0.00070.044410.0007
Mysqli_queries1.565094.83262000.0078
Looping result0.00220.13461980.0000
Template Total1.621698.320.8108
Template load0.00180.108120.0009
Template processing1.619998.153920.8099
Template load and register function0.00010.006310.0001
states
state_id_array0.00090.054010.0009
state_identifier_array0.00200.122320.0010
Override
Cache load0.00150.0935410.0000
Sytem overhead
Fetch class attribute can translate value0.00170.105830.0006
Fetch class attribute name0.00220.133060.0004
XML
Image XML parsing0.00090.052730.0003
class_abstraction
Instantiating content class attribute0.00000.001580.0000
General
dbfile0.00780.4756270.0003
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 29
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs