Hi everyone!
I recently updated my site to v6 from v2, and with that update, the word “contents” became a keyword. Previously, in a template, there would be (for example):
{exp:channel:entries channel="about_us" limit="1"}
{contents}
{/exp:channel:entries}
and the contents would appear. Now just “{contents}” appears. Does anyone know exactly what to change it to to fix this issue?
Thanks!
The variable {contents}
relates to the use of a feature of EE called template layouts: a mechanism that lets you split the development of a template across several separate component templates.
When you have this approach in use you pass information from one template to the next by adding a tag to the top of the first (and any subsequent templates if you want to use more than two templates to create the page) that looks a bit like this:
{layout='template_group/template'}
When EE encounters this tag, it evaluates all of the EE tags in the template that contains the tag, saves the output and then goes to find the template specified in the layout tag. When EE starts processing that template all the information that you generated on the first template can be recalled into the second template by including the special variable {contents}
. (There are other ways of using template layouts, read the docs to find out more.)
If you are not using template layouts and you include the special tag {contents}
in your template, EE simply returns it unchanged - you get {contents} appearing in your output.
From what you describe it looks likely that during the update from EE2 to EE6 something has happened to your templates, and as a result your template layout arrangement is broken - so the template you are concerned about is trying to load information from a template that comes ‘before it’ in the template layout sequence, but that earlier template is not being run.
I would check that you are opening the right template - it might be that you should be opening some other template that then calls the one you have opened as part of a layout stack.
HTH
🐾
Hmm. I did do a little bit of looking into the layouts, but I wasn’t sure if that was the right direction. Would you say the best bet then is to restructure to use template layouts?
I should add that all pages have this same issue. I believe the previous developer of the site did not use layouts at all.
I am not sure of any other element in EE that uses the {contents}
tag - so if you are seeing it then presumably at some point the site design was using layouts (whether you were aware of it or not).
Advising you on whether to restructure your site is tricky without having a look at what you have now, and such disclosure is not a good thing to do in a public forum. So my suggestion is that you get someone familiar with EE and layouts to have a look at your site and give you some informed guidance.
If you want to discuss this further you are welcome to try and reach me either directly (contact info via jcogs.net) or reaching out to the EE community at the EECMS Slack.
HTH
🐾
Thought I might just add another thought or two to this one as well.
In your example template above.. {contents} could be a custom field from before template layouts were a thing as well…
As such, it might be worth checking to see if you have a custom field with a shortname of “contents” if, so, you could rename that, and update {contents} in your template to the new short name.
Also, for more on template layouts, it might be worth checking out the following 2 videos.
That’s actually exactly what it was Tom! but the field was deleted during the update, as it was part of an add-on that I didn’t move forward. Working on fixing it right now!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.