Forums / Setup & design / custom pagelayout for search results

custom pagelayout for search results

Author Message

Patrice Fortin

Tuesday 13 March 2007 3:08:23 pm

Hi people,

I am working on a website with 3 sections, each having its own pagelayout. I use override.ini.append.php in my siteaccess to set which pagelayout to take depending on the section.

I also want to show search results (content/search) using the same pagelayout, depending from which section I did the search, but I didn't find an <i>easy</i> way for doing it.

I tried using an url_alias defined from admin interface, (firstsite_search pointing to content/search) but when I use this url to access the search page, I look in the code and url_alias is not set in array $matchKeys, function handleResource in file eztemplatedesignresource.php.

Also, the section (still in $matchKeys) is 7 (firstsite section) when checking overrides for the search.tpl template, but it is back to 1 when the checking overrides for pagelayout.tpl.

I managed to make it work by modifying the kernel, but I'm sure there is a cleaner way. I changed in search.php:

if ( $http->hasVariable( "SectionID" ) )
{
    $searchSectionID = $http->variable( "SectionID" );
}

to

if ( $http->hasVariable( "SectionID" ) )
{
    $searchSectionID = $http->variable( "SectionID" );
    $GLOBALS['eZDesignKeys']['section'] = $searchSectionID ;
}

And of course I added an hidden post variable in the search form in the 3 custom pagelayouts.

Does someone have a nice way to do what I did by modifying the kernel ?

Thanks
Patrice

Patrice Fortin

Thursday 15 March 2007 11:07:16 am

The way I did it is wrong, because I will have to modify too many things in order to make it work (advanced search page, user registration page, contact form confirmation, etc, etc). I cannot modify all these files.

The site I'm working on is built on ez 3.9.0. On a site using ez 3.6.3, I don't have this problem. I mean, when I go to a page without a section, it keeps the last pagelayout used (I suppose because the section id is kept).

There is a record in the bug tracker which talks about exactly this. I tought it was a feature, but the person which sent the bug report is of course calling it a bug. See here: http://issues.ez.no/IssueView.php?Id=7924&ProjectId=3

If it was a bug, it is not marked as solved but it is no longer occurring (at least for me in 3.9.0). If it is a feature, there is surely some config to enable to make it work in 3.9.0 as in 3.6.3.

Thanks
Patrice

Felix Woldt

Friday 16 March 2007 1:27:50 am

Hi Patrice,

i think their are two ways:

(1)
- create a dummy contentobject called search_node
- create an override template for this node
- use the template fetch function 'search' to get searchresult
http://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/search
( with ezhttp and the viewparemters you have access to all variables passed to this node)

(2)
- create a new extension called e.g. myspecialsearch
- copy the search.php from kernel and the module.php ...
- edit the search.php template and add the following to use another pagelayout

$Result['pagelayout'] = 'your_cutstom_pagelayout.tpl';

Felix

http://www.jac-systeme.de - Developers united in eZ Publish: http://www.cjw-network.com

CJW Newsletter 1.0.0 released: http://projects.ez.no/cjw_newsletter

Patrice Fortin

Friday 16 March 2007 7:04:09 am

Hi Felix,

thanks for your ideas. It would work if it was only for the search page. But as I said in the second post, I will have to do that kind of trick for every page not in a section. This means: search results, advanced search, kernel error pages, confirmation page after sending contact form, confirmation page of almost everything since it is out of every section.

What if I have a different siteaccess for every 'section' (which I would no longer call section) using the same database, having the same admin interface ?

Felix Woldt

Friday 16 March 2007 7:31:20 am

Hi Patrice,

You want to have for every section one pagelayout for all stuff like search, errors and so on.

Then i think a seperate siteaccess for every section will help. We have a lot of sites doing this. Their are no problems to have one admin for all 2 sites, but if you want to have special ini settings you need a seperate admin siteaccess for every section on the same database.

best regards
Felix Woldt

http://www.jac-systeme.de - Developers united in eZ Publish: http://www.cjw-network.com

CJW Newsletter 1.0.0 released: http://projects.ez.no/cjw_newsletter

Patrice Fortin

Friday 16 March 2007 12:28:03 pm

Thanks Felix!

I will have one siteaccess per section (my 3 sections), with the same design folder, but each with its own settings folder. I will create 3 pagelayouts with different names and I will modify override.ini in each siteaccess settings to get the right pagelayouts.

I will use a single admin interface.

Thank you very much.