Hi!

I can't imagine any other solution than the marker-property, but would be 
interested to hear what other people have to say on this! 
After all, the information that the page has been rendered once needs to be 
stored somewhere for you to be able to check it.
Currently, magnolia does not change the page or metadata on rendering (AFAIK) - 
none of the metadata properties are relevant to rendering, they are all set 
when editing.

So, in the execute() method of your model, you could simply set a property, as 
you suggest. It seems a fine solution to me.

Keep in mind that this property will be set on edit in the authoring system, 
and will then be published to each public system. So depending on what you are 
trying to do, you may need to account for that in your logic - i.e., record the 
system (author, public) name in the property, and check for equality with the 
current system name as well, in order for your logic to run again on the public 
instance!

Greetings from Vienna,

Richard



-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] 
Im Auftrag von Nils Breunese
Gesendet: Freitag, 08. Oktober 2010 15:32
An: Magnolia User-List
Betreff: [magnolia-user] Detect model class first run


Hello,

I have some logic in a template model class that I would like to execute only 
the first time the model class is executed for a page.

My first thought was to check the creation and modification dates, but since a 
page is usually named after being created, but before it is opened (which is 
when the model class is executed), this is not failsafe.

Is there a best practice way to know for sure whether a model class is being 
executed for the first time for a page?

A failsafe method I can think of is checking for some marker property: only run 
the first time logic when the marker property is not set and set it if it is 
not set at the end of the execution. This method would probably work, but feels 
dirty, so I'm open to other suggestions.

Thanks, Nils.
------------------------------------------------------------------------
 VPRO
 phone:  +31(0)356712911
 e-mail: [email protected]
 web:    www.vpro.nl
------------------------------------------------------------------------


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





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

Reply via email to