Cody CMS
Fork me on GitHub

Accessing Content

Q: How do I access a specific content block from my page in a .ejs view file?

A: Content block are in an array "content" of the page object, you can access them

  • Through the array: page.content[0], [1], ...
  • But cleaner is: page.getContentByIndex([nr of the desired block]) -> starting at 0 and can change if a webmaster reordens the content of a page.
  • You can call page.getContentByName("[name of desired content block]") 
    -> see how to name a content block in "FAQ -> Global Content"
  • If you know the ID of the block: page.getContentById([id of the content]) 
    -> see database