Content not showing values for the attribute "page"

We’re having some issues regarding Content Studio’s template and I’d like some help to understand if that’s normal behavior or a bug.

I have a template configured for specific content and on this template, I have a page, layout, and a part that was added long after the existence of the template. This part contains a form with inputs that we obviously need, but we use these values by querying for the content and accessing the attributes of the object “page” (“content.page.regions.main.components”).

My problem is that for the existing and new content that uses this template we do not have any value set on the “page” attribute, just an empty object, and I also noticed that this is happening for every content that uses a template.

What I didn’t understand is that when we create and publish the content it is still and empty object, although, when we customize the page of the content the page status goes to “Mark as Ready” and we publish it again, except this time all the information of the attribute “page” appears.

Enonic 7.4.1
Content Studio 3.0.3

So:
a) You have a part that is placed on a template
b) Within this part you are searching the page to access configuration of the same part.
c) when rendering a content that uses this template, it does not work.

First thing is that you should generally never lookup component configurations via the page (unless you are in the page controller). You can simply acess the components context to get its config.

The reason why your setup does not work is basically that the component does not exist as data on your current content/page. It does not have a page config, because that is stored on the template. The template is only used during the rendering process, and does not existi on your persisted data.

When customising the page, the templates data is copied to your current page - and then it starts working.

1 Like