Page 1 of 1

[solved] Search module: integrate results into page template

Posted: Tue Mar 04, 2014 8:20 pm
by 10010110
Is it possible to integrate the search results template more deeply into a page template? For example, I want the {$searchresultsfor} “{$phrase}” display as page title (i. e. as replacement for {title} in the page template).

A simple illustration:

Code: Select all

<!-- page template -->
<h2>{title}</h2>
{* content tag comes here, displaying the results template *}
↓
<!-- results template starts -->
<h3>{$searchresultsfor} „{$phrase}“</h3>
{if $itemcount > 0}
…
…
This is how it currently works and I want the heading of the results template as page title/heading.

How would I accomplish that?

Re: Search module: integrate results into page template

Posted: Tue Mar 04, 2014 9:44 pm
by velden

Re: Search module: integrate results into page template

Posted: Wed Mar 05, 2014 8:16 pm
by 10010110
Unfortunately this doesn’t appear to work, velden.
I’ve put

Code: Select all

{title assign='title'}
at the very top in my template, replaced all occurrences of {title} with {$title} (e. g. in the page header) and in the search results template I’ve put

Code: Select all

{assign var='title' value="$searchresultsfor “$phrase”"}
but the default page title is still shown. Apparently the results template code is not parsed before the page template code (or the header). Or am I missing anything?

Re: Search module: integrate results into page template

Posted: Fri Mar 07, 2014 2:59 am
by Rolf
Also pas the main content block through Smarty like in http://docs.cmsmadesimple.org/layout/ex ... e-template

Re: Search module: integrate results into page template

Posted: Fri Mar 07, 2014 8:19 am
by velden
Make sure that first line is BEFORE the opening <__html> tag. That is important!

http://www.i-do-this.com/blog/Under-the ... mplates/57

Re: Search module: integrate results into page template

Posted: Fri Mar 07, 2014 3:27 pm
by 10010110
Thanks Rolf, your suggestion did the trick.

There is/was one thing to note, though: Obviously the assignment of the title variable (or any variable?) doesn’t like UTF-8 characters. Or perhaps it’s an issue with the server/DB encoding? I had to convert my curly quotes to HTML entities, otherwise it would display black diamonds with questionmark in them. But in regular pages UTF-8 works, so… ???