laurent le cadet
|
Wednesday 29 August 2007 11:46:07 pm
André, What you propose is what I need = just clear the content cache of direct children.
create a enhancement issue for adding ClearCacheMethod[]=children
So I tryed this as I don't really know what you mean:
[product]
DependentClassIdentifier[]
DependentClassIdentifier[]=company
ClearCacheMethod[]
ClearCacheMethod[]=children
But it doesn't seems to be enough. Could you tell me more. Thanks. Laurent
|
laurent le cadet
|
Thursday 30 August 2007 12:55:10 am
Hi Bruce, So here is the company.tpl
{def $currentimestamp = currentdate()
$debuttimestamp = $node.object.data_map.debut_abonnement.data_int
$fintimestamp = $node.object.data_map.fin_abonnement.data_int
$approbation = $node.object.data_map.approbation.data_int
$children = fetch('content','list',hash( parent_node_id, $node.node_id,
sort_by, $node.sort_array ) )
$children_count = $children|count()}
<div class="content-view-full">
<div class="class-entreprise">
{if $approbation}
<h1>{$node.data_map.societe.content|wash()}</h1>
<div class="logo">
{attribute_view_gui attribute=$node.data_map.logo image_class=medium alignment=right}
</div>
<div class="break"></div>
<div class="adresse">
<ul>
<li>{attribute_view_gui attribute=$node.data_map.adresse}</li>
<li>{attribute_view_gui attribute=$node.data_map.code_postal}</li>
<li>{attribute_view_gui attribute=$node.data_map.ville}</li>
<li>{attribute_view_gui attribute=$node.data_map.pays}</li>
<li>{attribute_view_gui attribute=$node.data_map.telephone}</li>
<li>{attribute_view_gui attribute=$node.data_map.fax}</li>
<li>{attribute_view_gui attribute=$node.data_map.site_internet}</li>
</ul>
</div>
<div class="activite">{attribute_view_gui attribute=$node.data_map.activite_entreprise} ({attribute_view_gui attribute=$node.data_map.profil})</div>
{if $node.object.can_edit}
<ul>
<li>Effectif entreprise : {attribute_view_gui attribute=$node.data_map.effectif_entreprise}</li>
<li>Avantages abonnement : {attribute_view_gui attribute=$node.data_map.avantages_abonnement}</li>
</ul>
<h2>Votre abonnement</h2>
<p>Vous êtes inscrit sur zoneindustrie.com depuis le {$debuttimestamp|l10n(date)}.</p>
<p>
{if $node.data_map.fin_abonnement.content|not()}
{if gt(sum($debuttimestamp,7776000),$currentimestamp)}
Vous êtes actuellement en utilisation gratuite et votre entreprise ainsi que vos produits sont visibles jusqu'au {sum($debuttimestamp,7776000)|l10n(date)}
{/if}
{/if}
{if and($node.data_map.fin_abonnement.content, gt($fintimestamp,$currentimestamp))}
Vous êtes actuellement en abonnement payant et votre entreprise ainsi que vos produits sont visibles intégralement jusqu'au {$fintimestamp|l10n(date)}.
{/if}
{if and($node.data_map.fin_abonnement.content, lt($fintimestamp,$currentimestamp), gt(sum($fintimestamp,7776000),$currentimestamp))}
Vous n'êtes plus en abonnement payant et seul votre entreprise et vos 3 derniers produits sont visibles jusqu'au {sum($fintimestamp,7776000)|l10n(date)}.
{/if}
{if and($node.data_map.fin_abonnement.content, gt(sub($currentimestamp,7776000),$fintimestamp))}
Votre date d'abonnement est dépassée et seule votre entreprise est présente sur zoneindustrie.com.<br>
Vos produits sont actuellement masqués.<br>
<a href="#">Renouveler votre abonnement</a>
{/if}
</p>
{else}
{if gt($fintimestamp,$currentimestamp)}
<div class="content-view-children-three">
{section var=child loop=$children}
{node_view_gui view='line' content_node=$child}
{delimiter modulo=1}
</div>
<div class="content-view-children-three">
{/delimiter}
{/section}
</div>
<div class="break"></div>
{/if}
<div class="attribute-tipafriend">
<p>
<a href={concat('/content/tipafriend/',$node.node_id)|ezurl}>{"Tip a friend"|i18n("design/base")}</a>
</p>
</div>
{/if}
{else}{* APPROBATION *}
Finalisation de l'inscription de cette entreprise en cours.
{/if}
</div>
</div>
Tha's the $fintimestamp = $node.object.data_map.fin_abonnement.data_int I refer to while showing the children of the company node, like this in product.tpl:
{def $currentimestamp = currentdate()
$objectimestamp = $node.object.data_map.date_marche.data_int
$parentimestamp = $node.parent.data_map.fin_abonnement.data_int
$email = $node.contentobject_version_object.creator.data_map.compte_utilisateur.content.email}
<div class="content-view-full">
<div class="class-produit">
<h1>{$node.data_map.nom.content|wash()}</h1>
{if gt($objectimestamp, sub($currentimestamp, 7776000))}
<div class="new">
<img src={"images/icon_nouveaute.gif"|ezdesign} height="11" width="48" title="Nouveauté" alt="Nouveauté" />
</div>
{/if}
{attribute_view_gui attribute=$node.data_map.image image_class=medium alignment=right}
{if $node.data_map.marque.content}
{attribute_view_gui attribute=$node.data_map.marque}
{/if}
{attribute_view_gui attribute=$node.data_map.presentation_produit}
{if ge($parentimestamp,$currentimestamp)}
{if $node.data_map.descriptif_detaille.content}
{attribute_view_gui attribute=$node.data_map.descriptif_detaille}
{/if}
{if $node.data_map.documentation.content}
{attribute_view_gui attribute=$node.data_map.documentation}
{/if}
<div class="break"></div>
<form method="get" action="/contact">
<input type="hidden" name="produit" value="{$node.data_map.nom.content}" />
<input type="hidden" name="email" value="{$email}" />
<input type="image" class="btn-info-produit" src={"1x1.gif"|ezimage} />
</form>
{/if}
<div class="break"></div>
<div class="attribute-tipafriend">
<p>
<a href={concat('/content/tipafriend/',$node.node_id)|ezurl}>{"Tip a friend"|i18n("design/base")}</a>
</p>
</div>
</div>
</div>
In that template : $parentimestamp = $node.parent.data_map.fin_abonnement.data_int {if ge($parentimestamp,$currentimestamp)}...{/if} I know this kind of comparison is a bit out of the normal content view. Is that clear enough? Laurent
|
laurent le cadet
|
Thursday 30 August 2007 11:43:45 pm
yes Bruce, I think too that the cache-block is the best solution, but I'm not really a cache-block killer and I know a bad templating can be a real performance disaster.
What I know is that we can use the ttl for the content view cache. So if I follow your hint, it should be first like this (in product.tpl) :
{set-block scope=root variable=cache_ttl}0{/set-block}
...and then something more?
{cache-block subtree_expiry=$node.parent.node_id}
my product template code.
{/cache-block}
Please, correct me if I'm wrong. Laurent
|
André R.
|
Friday 31 August 2007 1:11:25 am
The most optimized way should be:
{cache-block subtree_expiry=concat('content/view/full/', $node.parent_node_id )}
my product template code.
{/cache-block}
BUT! If you have lots of products and they change often, all products cache will be cleared, so it might be better to do something like:
{def $parentimestamp = $node.parent.data_map.fin_abonnement.data_int}
{cache-block keys=$parentimestamp subtree_expiry=concat('content/view/full/', $node.node_id )}
{def $currentimestamp = currentdate()
$objectimestamp = $node.data_map.date_marche.data_int
$email = $node.contentobject_version_object.creator.data_map.compte_utilisateur.content.email}
my product template code.
{/cache-block}
eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom
|
laurent le cadet
|
Friday 31 August 2007 2:46:56 am
André, Fine tunning :
{set-block scope=root variable=cache_ttl}0{/set-block}
{def $parentimestamp = $node.parent.data_map.fin_abonnement.data_int}
{cache-block keys=$parentimestamp subtree_expiry=concat('content/view/full/', $node.node_id )}
{def $currentimestamp = currentdate()
$objectimestamp = $node.object.data_map.date_marche.data_int
$email = $node.contentobject_version_object.creator.data_map.compte_utilisateur.content.email}
.... Additionnal template code here ....
{/cache-block}
{set-block scope=root variable=cache_ttl}0{/set-block} is necessary first to kill the ttl ? Laurent
|
Vincent Lepot
|
Monday 03 September 2007 11:20:08 am
I'm coming back on André suggestion. I think that the Smart cache clear part of the code should be extended by user code (I mean in an extension surdir for example). I had a similar problem where cache-block can't help me (I wanted to invalidate cache of objects related to objects related to my content... ok, it seems stupid, but in my context, it was necessary). Moreover, keeping content view cache is better to keep correct performance (cache-block use suppose node view template execution every time you call the page). Do you think it's a stupid idea, or shall I create an enhancement request in this way ?
|