Forums / Developer / Separate pagelayouts for 'view' and 'edit' - NOT POSSIBLE?

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

eZ debug

Timing: Jan 31 2025 04:59:20
Script start
Timing: Jan 31 2025 04:59:20
Module start 'content'
Timing: Jan 31 2025 04:59:20
Module end 'content'
Timing: Jan 31 2025 04:59:20
Script end

Main resources:

Total runtime0.2887 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0094 588.0781180.8125
Module start 'content' 0.00940.0070 768.8906101.9609
Module end 'content' 0.01640.2723 870.8516530.2031
Script end 0.2887  1,401.0547 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00341.1906200.0002
Check MTime0.00140.4750200.0001
Mysql Total
Database connection0.00080.285010.0008
Mysqli_queries0.236982.06151410.0017
Looping result0.00130.45831390.0000
Template Total0.272094.210.2720
Template load0.00080.279510.0008
Template processing0.271293.908810.2712
Override
Cache load0.00060.194610.0006
Sytem overhead
Fetch class attribute can translate value0.00100.348710.0010
XML
Image XML parsing0.00040.146510.0004
General
dbfile0.00963.3259200.0005
String conversion0.00000.002530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

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

Time used to render debug report: 0.0002 secs