Developer's Blog

Entries from July 2009

Using the Search Language to search across associations

Posted July 08, 2009 by Justin Lewis. Filed under Code.

Interface has a unique Search Language that allows you to easily search for content, from simple queries on one field to multiple grouped conditional statements. Also, because content can have associated items, there is the ability to search across those associations. Here’s how.

Using Search in Content Tag

Assuming your model is called Product, place the following in your template:

<% content_tag(:model => :product).each do |product| -%>
<h3><%= product.name %></h3>
<% end -%>

That will get all content from the Product model. But what if you wanted to show only Products that had a certain ProductCategory?

<% content_tag(:model => :blog_item, :find => "product_category.name!Widgets").each do |product| -%>
<h3><%= product.name %></h3>
<% end -%>

Even more, you can search across any time of association. If the Product has multiple ProductCategories, you could also do:

<% content_tag(:model => :blog_item, :find => "(product_categories.name!Widgets|product_categories.name!Thingies)").each do |product| -%>
<h3><%= product.name %></h3>
<% end -%>

Which would pull all Products that are in either the Widgets or Thingies ProductCategories.

Using the API

You can use the same Search Language in the API to pull content:

http://yoursite.interfacecms.com/api/product.xml?search=(product_categories.name!Widgets|product_categories.name!Thingies)

For more on info, see the Search Language Documentation and the Content Tag Documentation in the Interface User Manual.

Add comment

Blueprint CSS Framework

Posted July 02, 2009 by Justin Lewis. Filed under Tips.

Blueprint is a CSS framework, which aims to cut down on your development time. It gives you a solid foundation to build your project on top of, with an easy-to-use grid, sensible typography, useful plugins, and even a stylesheet for printing.

Read more at blueprintcss.org

Add comment