21282 Posts in 5730 Topics by 2601 members
|Go to End|
4 May 2011 at 5:40pm
<% cached 'getAllNews', Aggregate(News).Max(LastEdited) %>
<% if getAllNews %>
<% control getAllNews %>
<li><a href="$Link" title="$Title">$Title</a></li>
// I wanna uncache TotalLike field like this
<% end_control %>
<% end_if %>
<% end_cached %>
7 May 2011 at 7:13pm
nobody help me ..
8 May 2011 at 12:56am
In http://doc.silverstripe.org/sapphire/en/reference/partial-caching somewhere it states:
Currently cached blocks can not be contained within if or control blocks. The template engine will throw an error letting you know if you've done this. You can often get around this using aggregates.
I guess the same goes for uncached blocks, so I don't think it can be done this way.
8 May 2011 at 3:06am
I hope this feature will be implement into SS in the future
8 May 2011 at 1:40pm
You could use the # of likes as part of the cache key. So rather than using LastEdited define your own key (http://doc.silverstripe.org/sapphire/en/reference/partial-caching#cache-key-calculated-in-controller) which uses page id + likes + last edited to generate a unique key.
Or you could load the like values using ajax which is fired off when the page loads. That request would return something like whether the user has liked it and the count of likes. Though looking at your example I can't see how you're passing back whether the user has voted or note.
|Go to Top|