Cody CMS
Fork me on GitHub

Global Content

Q: How do I make content that I want to use in many different place in my website editable by the webmaster?

A: Put it "named" in an (from your view) easy accesible page.

 

Q: How do I name a content block?

A: Content blocks (before they are created) can be named in the template (see default content). Whenever a new page is created the content blocks are added with the given name. Also Super Users can click on the "Adjust" button and missing content blocks are added.

For the moment we don't have an interface for renaming existing content. You will need to change its name in the SQL database. Update the correct content record in the table "content" by setting the "name" column to the desired name and restart the node.js app.

 

Q: How do I find this "easy accesible page"?

A1: Some are very easy:

  • The root page of your website:  page.root
  • The parent of the current page:  page.parent
  • Example: first of its children:  page.children[0]

A2: You can find any page you want:

  • app.getPage("[language]",[id])
  • app.getPage("[language]/[link]")

 

Example: the Google Analytics code in the footer (of header) of your page.

<% var analytics = page.root.getContent("Google Analytics code"); %>
<% if (typeof analytics !== "undefined") { %>

<% } %>

 

More examples:

- Global Content

A safe but dynamic footer

  <% var first = page.root.getContent('footer.first'); %>
  <% var second = page.root.getContent('footer.second'); %>
  <% var third = page.root.getContent('footer.third'); %>

  <% if (first && (typeof first !== "undefined")) { %>
    <%- first.render() %>
  <% } %>
  <% if (second && (typeof second !== "undefined")) { %>
    <%- second.render() %>
  <% } %>
  <% if (third && (typeof third !== "undefined")) { %>
    <%- third.render() %>
  <% } %>