Change data of a page on the fly

Is there an elegant way to add extra values (methods?) to a page object on the fly? I don’t want to modify the database, just edit the object before it’s displayed.

I’m trying to do something like what is asked in this other threat, just not onto a File object but onto a Page object.

(For context, what I’m doing it passing a Collection of Pages to a snippet that loops through it, and at a late stage I’ve realized some values taken from other pages or processing, would need to be added into the loop. I thought the cleaner way would be to have them pushed inside the object. If that doesn’t work I’m looking into just storing them in an array and associating them by UID.)

If it is for a specific template, you should have a look at page models.

So that is what page models are for. :smile:

Thanks, @bvdputte!