I am sure this is something really basic but here goes.
I an trying to find the best way to be able to update site content in places like the header/footer and maybe the sidebar, this is info which will be on on pages like address phone number etc.
My thought is to do this with getpage or getresources by creating a new template and assigning some TV to it then create a new document which uses this new template and call it something like settings which would have some rich text TV fields to update the header or footer content and then in the getpage template just include the required TV.
I just wondered it there was another way or this the best solution.
Many thanks
Ian
-
☆ A M B ☆
- 80 Posts
There are multiple ways to do this.
The way you describe, using TV's attached to a resource that will contain the site settings and then grabbing those TVs with getResources or getResourceField will work well, especially if you need to have that info editable as a part of a resource. This method can also work well when you have multiple areas on your site with different site info. I've used parent pages with special TV's to set all of the site info in the children this way (just use something like getResourceField with UltimateParent).
You can also use chunks. And if you want to more easily change the information in the chunks, look into attaching property sets to the chunks. Chunks are probably more efficient as long as you don't need the info to be part of a resource.
And there are even more ways, but I think the above are common.
Time is what keeps everything from happening all at once.
+1 for what paulmerchant said.
getResources and getPage can be very slow, especially so when they need to retrieve TVs.
If you put the information in a chunk (or several chunks), it will already be formatted, is easily updated, and can be displayed anywhere with a chunk tag in the template:
Ian, actually I removed that part from the message once I realized that the TV would have to be edited separately for each page on the site.
One option might be to create a dedicated (unpublished) Resource for each section, then use the getResourceField snippet (rather than a TV) to get the content field from the appropriate resource.