Pop Tags

A power tool to filter and organize content. lets you search through the content of the site, similar to <pop:search>.

The site search is quite flexible. In its simplest form it works by passing in a query:{query: "webpop"})

Will return content on your site matching the query “webpop”. This returns an object with the following properties:

obj.results An array of content objects
obj.length The total results matching the search

By default the search will only return content that has a template attached. To get all content set the “all” option to true:{query: "webpop", all: true})

You can use the “page” and “per_page” options to handle pagination:{
query: "webpop",
per_page: 10,
page: 2

You can limit the results to a specific type (“section”, “entry” or “category”) by setting the “type” attribute.{
query: "webpop",
type: "entry"

You can add filters to the search with the “filters” attribute:{
  query: "webpop",
  type: "entry",
  filters: {
section_id: site.content({from: "blog"}).id
} })

You can also limit the search to be inside a specific section:{
  query: "webpop",
  within:  site.content({from: "blog"})

Filters can also handle date ranges:

// Return content published in 2011{filters: {published_at: "2011"}})

// Return content from January 2011{filters: {published_at: "2011-01"}})

// Return content from January 1 2011{filters: {published_at: "2011-01-01"}})

// Return content from the first week of January 2011{filters:{
published_at: {
from: new Date(2011, 01, 01),
to: new Date(2011, 01, 8)
}) // Only content with a field called "date" with a date in the future{filters: {date: "future"}}) // Only content with a field called "date" with a date in the past{filters: {date: "past"}})


You can also use the site search to generate timelines. This example would generate a timeline object of all the entries within the blog section.{
type: "entry",
within: site.content({from:"blog"}),
timeline: {published_at: "month"}

A timeline is an array of objects with the following properties:

obj.start First date in the period
obj.end Last date in the period
obj.count Number of results for this period

You can use “day”, “week”, “month” or “year” as a period for timelines.

Timelines are useful whenever you need to organize content chronologically. For example, building a tour date calendar.

Continue to The Request Object »