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.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 05:58:17
Script start
Timing: Jan 31 2025 05:58:17
Module start 'layout'
Timing: Jan 31 2025 05:58:17
Module start 'content'
Timing: Jan 31 2025 05:58:17
Module end 'content'
Timing: Jan 31 2025 05:58:17
Script end

Main resources:

Total runtime0.0178 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0077 588.2500151.2266
Module start 'layout' 0.00770.0035 739.476636.6797
Module start 'content' 0.01120.0052 776.156398.2813
Module end 'content' 0.01640.0014 874.437537.9922
Script end 0.0178  912.4297 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002715.2680140.0002
Check MTime0.00126.7450140.0001
Mysql Total
Database connection0.00074.101210.0007
Mysqli_queries0.005128.773930.0017
Looping result0.00000.094810.0000
Template Total0.00105.510.0010
Template load0.00074.006410.0007
Template processing0.00031.496210.0003
Override
Cache load0.00052.822810.0005
General
dbfile0.00095.256880.0001
String conversion0.00000.054840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs