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

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 09:08:37
Script start
Timing: Jan 19 2025 09:08:37
Module start 'layout'
Timing: Jan 19 2025 09:08:37
Module start 'content'
Timing: Jan 19 2025 09:08:37
Module end 'content'
Timing: Jan 19 2025 09:08:37
Script end

Main resources:

Total runtime0.0230 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0070 589.1484152.6250
Module start 'layout' 0.00700.0064 741.773439.4453
Module start 'content' 0.01350.0072 781.218893.4297
Module end 'content' 0.02060.0023 874.648434.3047
Script end 0.0229  908.9531 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002912.4525140.0002
Check MTime0.00146.0316140.0001
Mysql Total
Database connection0.00114.589610.0011
Mysqli_queries0.006327.301030.0021
Looping result0.00000.100710.0000
Template Total0.00198.210.0019
Template load0.00114.758810.0011
Template processing0.00083.457010.0008
Override
Cache load0.00083.500610.0008
General
dbfile0.003213.939180.0004
String conversion0.00000.039440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_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