Hi,

1) Why would you want to implement this? Page counters are so 1990s... if it is 
for the purposes of stats, then why not use something like Google Analytics, or 
Piwik if you want to install your own...

2) Assuming you absolutely need it, here is my take on a possible 
implementation:

- you don't want to put it as part of the page rendering process. It will be a 
nightmare for caching your content, and there are contention (synchronization) 
issues to consider. Basically it would be very slow.
- you don't want to store the counters as part of the content. They would be 
overwritten when you re-publish the pages, etc...
- so, instead, I would begin implementation with a javascript component on the 
frontend that makes an AJAX call to increment and read the counter value. The 
result can be returned as JSON and put into the page where it is needed by the 
javascript
- on the backend, I would make a REST service for the counter, which can manage 
different counters based on IDs (keys). For webpage counters the ID could 
simply be the URL, or the page's UUID. The REST service offers methods like GET 
/counter/<id> (read)  or POST /counter/<id> (read and increment).
- The REST service stores the counter values in some backend. One option might 
be JCR, but another might be just SQL or even a no-SQL option like redis. Not 
entirely sure what would be best, but JCR is probably on the slow side for 
storing counters.
- The REST service could be implemented extending magnolia's REST APIs, or just 
as a servlet.

Regards from Vienna,

Richard



> -----Ursprüngliche Nachricht-----
> Von: [email protected] 
> [mailto:user-list-owner@magnolia- cms.com] Im Auftrag von ??????? 
> ????????? (via Magnolia Forums)
> Gesendet: Montag, 15. August 2016 13:18
> An: Magnolia User List
> Betreff: [magnolia-user] Page view counter
> 
> Hello again.
> 
> What is the best way to implement view count for Page?
> 
> For now i created filter. Get aggregation state. Get node to render. 
> Check cookie, if no page id in cookie try to increment "visited" value.
> This flow is working, but incremented value do not saved. This code do
> nothing:
> [code]
> Node pageNode = aggregationState.getCurrentContentNode();
> // increment here
> pageNode.getSession().save();
> [/code]
> Why?
> 
> And second thing, if user with role anonymous will get such page he 
> will need write access to increment field. I think it is not a good 
> idea. Is it possible to write in filter as another(writer) user role?
> 
> --
> Context is everything: http://forum.magnolia-
> cms.com/forum/thread.html?threadId=7f2fed1f-be18-41fa-ad9e-
> 3632a2bb49b1
> 
> 
> ----------------------------------------------------------------
> For list details, see http://www.magnolia-cms.com/community/mailing-
> lists.html
> Alternatively, use our forums: http://forum.magnolia-cms.com/ To 
> unsubscribe, E-mail to: <[email protected]>
> ----------------------------------------------------------------



----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to