Separate pagelayouts for 'view' and 'edit' - NOT POSSIBLE?

Author Message

Sven Berg Ryen

Monday 22 December 2003 9:13:14 am

Hi!

A quick question before the holidays:

A client of mine needs to have a different pagelayout for displaying and editing posts to a forum.

How can I achieve this? Is there some option in override.ini.php (like section, node, etc)? We're currently using version 3.1-1 R2703.

I tried using "/layout/set/.../content/edit/...", but that wasn't a suitable solution.

Cheers,

Sven Ryen
sven.ryen at maxus.no

Balazs Halasy

Monday 22 December 2003 9:33:48 am

First of all, you should really consider upgrading eZ publish to the latest stable version. 3.1-1 is kinda old. :-)

Regarding the pagelayout question:
You could do something like this (pseudo-code only!) inside your main/original pagelayout.tpl file:

if requested URL contains "edit"
{
include my_edit_pagelayout.tpl
}
else
{
include my_view_pagelayout.tpl
}

The if-then-else mechanism could be easily solved with a "section" block. The include can be solved using the "include" function. The URL can be extracted from the "$module_result.uri" - use one of the string operators to check if "edit" or "view" exists in the URL.

Another solution would be to check if a user is logged in or not and generate/include different pagelayouts based on that. Example:

{* Fetch the current user. *}
{let user=fetch('user', 'current_user', hash() )}

{* If user is logged in: *}
{section show=$user.is_logged_in}

Logged in: {$user.login}<br />

{* Include my custom layout template for edit... *}

{* Else: there is no user logged in... *}
{section-else}

{* Include my custom layout template for view... *}

{/section}
{/let}

I hope this helps.. :)

Balazs

Paul Borgermans

Monday 22 December 2003 10:30:00 am

Alternative (ez publish is a bit like Perl, there is more than one way to do it):

I hacked

kernel/content/attribute_edit.php

and added 1 line

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

at the end of the file after $Result['path'] = $path;

---------somewhere around line 376 in 3.2-3-----
$Result['path'] = $path;
$Result['pagelayout'] = 'pagelayout_edit.tpl';
--------------------------------------------------------

Additional benifit: you can use pagelayout_edit.tpl also in the override mechanism for different sections, classes, .... after you upgrade to 3.2-x

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Balazs Halasy

Monday 22 December 2003 10:47:00 am

Great hack Paul! :-) However, regular users of eZ publish shouldn't be messing around with kernel code (because of security issues, future upgrades, etc.). Thats why I suggested a less violent/hacker-style approach...

Balazs

Bruce Morrison

Monday 22 December 2003 2:26:14 pm

Hi Paul

I've also hacked the ezPublish code to work around issues or to gain functionallity but have come unstuck when performing upgrades, especially if the files I have changed are significantly different between versions.

How do you manage upgrades when you are changing the ezpublish core code?

Cheers
Bruce
http://www.designit.com.au

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Paul Borgermans

Tuesday 23 December 2003 1:37:04 am

Hi Bruce,

I and my collegues only do minimal changes to kernel code, almost everything is in extensions (sometimes copies of kernel code/operators/datatypes with another name if the changes are substantial)

Currently I keep the changed files in a svn server. That's easy for tracking, diffing, ...

cya

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

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 19 2025 03:21:52
Script start
Timing: Jan 19 2025 03:21:52
Module start 'layout'
Timing: Jan 19 2025 03:21:52
Module start 'content'
Timing: Jan 19 2025 03:21:53
Module end 'content'
Timing: Jan 19 2025 03:21:53
Script end

Main resources:

Total runtime0.8885 sec
Peak memory usage4,096.0000 KB
Database Queries70

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0038 589.3047152.6406
Module start 'layout' 0.00380.0019 741.945339.4766
Module start 'content' 0.00570.8815 781.4219667.3906
Module end 'content' 0.88720.0013 1,448.812516.1094
Script end 0.8885  1,464.9219 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00280.3116160.0002
Check MTime0.00120.1382160.0001
Mysql Total
Database connection0.00050.052910.0005
Mysqli_queries0.802490.3060700.0115
Looping result0.00080.0952680.0000
Template Total0.860896.920.4304
Template load0.00200.221120.0010
Template processing0.858896.651620.4294
Template load and register function0.00020.027410.0002
states
state_id_array0.00110.126310.0011
state_identifier_array0.00120.133820.0006
Override
Cache load0.00180.2001690.0000
Sytem overhead
Fetch class attribute can translate value0.00100.108240.0002
Fetch class attribute name0.00110.125790.0001
XML
Image XML parsing0.00230.257540.0006
class_abstraction
Instantiating content class attribute0.00000.0027110.0000
General
dbfile0.00110.1238290.0000
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
14content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
8content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 35
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs