Forums / Setup & design / User-Specific caching

User-Specific caching

Author Message

Marco Zinn

Saturday 21 May 2005 5:49:56 am

Hi,
I'm setting up a site, where users can create objects and are allowed to edit these "self-owner" objects. It's just the same as the forum here, i guess.
Issue: AFAIK, the content caching works based on the role combination. That won't help me, as all users share the some policy set.
So, by ez's default, all users can see the "edit"-button for all user-created objects, no matter, if they own it or not. They can't actuelly edit the content, but i want to hide the edit button, if they can't edit the object anyway.
I'm using a section checking for "object.can_edit" in line and full views.

Of course, i have a caching issue here: If the first user visiting the page CAN edit the content, i'll have that button in the cached content file, and others users (with the same roles) will see that button!

What's the right way to do user-specific content caching. I'm NOT talking about pagelayout; in pagelayout, i can use cache-blocks with user-id-specific key. But how to do this in the "content area"?

Marco
http://www.hyperroad-design.com

Paul Borgermans

Saturday 21 May 2005 2:40:43 pm

Hi Marco,

1) You need to fetch the current user in the content {$module.result} related templates and use that to setup a cache block key

or

2) disable caching for that template.

But

3) I don't have that problem in my sites (all on 3.4.x though), so maybe you stumbled upon a bug. Can you provide more details (what policies are enabled and post the section statements where you check for $object.can_edit)

-paul

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

Marco Zinn

Sunday 22 May 2005 10:58:54 am

Hi,
Hm. I'm talking about "node view full" and "node view line" templates, not the pagelayout.tpl.
I thought, i cannot create cache-block within content templates?, so i didn't get your 1) .
Currently, i use 2) ;)

So, these are the most important policy parts:

content  	 create  	 Node( Mitglieder ) , Class( Character ) , Section( Standard )
content 	edit 	Owner( Self )

This should allow users to create objects of the "Character" class as children of the (Folder) Node "Mitglieder". This works fine.
The second line should allow the users to edit "his own" objects ("character" objects or others).

Templates:
For the "Mitglieder" Node, there is an full view override.
Most important part:

<table>
<tr halign="top">
{section name=Child loop=$children sequence=array(bglight,bgdark)}
<td>
{node_view_gui view=line content_node=$Child:item}
</td>
{delimiter modulo=3}
</tr><tr>
{/delimiter}
{/section}
</tr>
</table>

As you see, i call the line template.

In that line template, used this code

{section show=$node.object.can_edit} (Daten bearbeiten: <a href={concat("content/edit/",$node.contentobject_id)|ezurl}><img src={"edit.gif"|ezimage} alt="Bearbeiten" /></a>){/section}

As this didn't work (the Edit-Button appeared for objects, which the current user was not allowed to edit), i moved this code into the full-view-template and disabled caching for this full view template with

{set-block scope=root variable=cache_ttl}0{/set-block}

Marco
http://www.hyperroad-design.com

eZ debug

Timing: Jan 19 2025 06:22:00
Script start
Timing: Jan 19 2025 06:22:00
Module start 'content'
Timing: Jan 19 2025 06:22:00
Module end 'content'
Timing: Jan 19 2025 06:22:00
Script end

Main resources:

Total runtime0.1662 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.0070 588.9453180.8438
Module start 'content' 0.00700.0067 769.789197.9766
Module end 'content' 0.01360.1525 867.7656527.0000
Script end 0.1662  1,394.7656 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00412.4482200.0002
Check MTime0.00191.1524200.0001
Mysql Total
Database connection0.00090.539010.0009
Mysqli_queries0.115369.38721410.0008
Looping result0.00130.80361390.0000
Template Total0.152191.510.1521
Template load0.00080.479310.0008
Template processing0.151391.041010.1513
Override
Cache load0.00050.325410.0005
Sytem overhead
Fetch class attribute can translate value0.00110.643710.0011
XML
Image XML parsing0.00040.265810.0004
General
dbfile0.00472.8084200.0002
String conversion0.00000.004230.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.0001 secs