I’m looking to strategize how best to go about sharing data between page includes and the page it’s included on.
Specific scenario:
I have users each with their own “Department” field set on their User object. In order to pull this department field, I query the user object based on the ID of the current user. In all of my elements I may display things differently dependent on their Department. This is fine and good, except when it comes to using page includes.
Currently I am running this query to find out the user’s department on each page include, which is ineffecient and less than ideal.
I’d like to be able to share this data (User model) between page includes and the page it is included on, such that if the page it was included on has already loaded this data, the included page uses that model to base its logic on rather than having to query its own model.
However, if my page include does not have a parent page that queried the model, then at that point the page include should query the User itself, and then use that queried information.
-----
I can vaguely imagine using javascript “.window” to store models in “global” variables for this purpose. If the global variable exists, don’t query our local model and instead use that? What I’m not sure about: is it possible to override an existing model on a page with another model via javascript? Such that if the global model doesn’t exist, we query our local model, but if it does exist we replace our local model with the global one (maintaining the ability to work with the SKUID Editor using the model we overrided?)
I hope I’m explaining this correctly.
Any ideas?
Thanks!
Question
Query subpage (page include) model only if parent page model doesn't exist, otherwise use parent mod
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.