Guides
Tutorials
Pop Tags

Global Site Object

Accessing your site and content from extensions

All extensions can use the global site object to access to the entire content repository of the website. Each PopTag that pulls content into templates has a corresponding method on the site object for fetching it's content in extensions.

site.content(options) - This method corresponds to the <pop:content> tag in PopTags templates. It returna the current content assigned to the template if you pass no options. But you can use the from attribute just like in your templates. A blog section with the id “blog” can be accessed from an extension with:

var content = site.content({from: "blog"});

Once you have some content, you can always access the following properties:

  • content.id
  • content.title
  • content.description
  • content.permalink
  • content.url (absolute url)
  • content.slug
  • content.created_at
  • content.updated_at
  • content.published_at
  • content.published
  • content.author ({first_name: …, last_name: …, full_name: …, email: …})
  • content.type
  • content.section
  • content.current (true if this is the current content)
  • content.active (true if this is the current content or a child of this content is current)
  • content.parent (travels up the hierachy of contents. To the nearest section for sections or entries, and nearest category or section for categories)

site.entries(options)

Same as the <pop:entries> tag. Options can be from, skip, limit or except. Will return an array of entries.

site.categories(options)

Same as the <pop:categories> tag. Options can be from, skip, limit or except. Will return an array of entries.

site.sections(options)

Same as the <pop:sections> tag. Options can be from, skip, limit or except. Will return an array of entries.

site.home

An attribute returning the home section

site.url

An attribute returning the absolute url of the website (ie. http://www.webpop.com)

Continue to Site.search »