eZ Community » Forums » Developer » Separate pagelayouts for 'view' and...
expandshrink

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

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

Monday 22 December 2003 6:13:14 pm - 5 replies

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.

Monday 22 December 2003 6:33:48 pm

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

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.. happy.gif Emoticon

Balazs

Modified on Monday 22 December 2003 6:40:53 pm by Balazs Halasy

Monday 22 December 2003 7:30:00 pm

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

Monday 22 December 2003 7:47:00 pm

Great hack Paul! happy.gif Emoticon 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

Monday 22 December 2003 11: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

Tuesday 23 December 2003 10: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

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu