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.