[solved] Search module: integrate results into page template

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
10010110
Translator
Translator
Posts: 224
Joined: Tue Jan 22, 2008 9:57 am

[solved] Search module: integrate results into page template

Post 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?
Last edited by 10010110 on Fri Mar 07, 2014 3:28 pm, edited 1 time in total.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Search module: integrate results into page template

Post by velden »

10010110
Translator
Translator
Posts: 224
Joined: Tue Jan 22, 2008 9:57 am

Re: Search module: integrate results into page template

Post 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?
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Search module: integrate results into page template

Post by Rolf »

Also pas the main content block through Smarty like in http://docs.cmsmadesimple.org/layout/ex ... e-template
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Search module: integrate results into page template

Post 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
10010110
Translator
Translator
Posts: 224
Joined: Tue Jan 22, 2008 9:57 am

Re: Search module: integrate results into page template

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

Return to “Modules/Add-Ons”