If you use Builder a lot, chances are you’re pretty familiar with Layouts … but what about Views? A surprising number of people haven’t used Builder Views or don’t understand how they work. This week, we’ll break it down so you can get the most out of your Builder theme by utilizing Views.
Understanding iThemes Builder Views
Chances are, you’ve seen the Views tab inside your theme’s Layouts & Views page (it’s in the name, after all), but may not have ever used it.
Layouts are pretty straightforward, but what are “Views” exactly? To put it simply, Views are a method of assigning a default Layout to specific content across your site.
Think of Views like email filters; by setting them up ahead of time, any new emails of that predefined type will be dealt with in a specific way. In much the same way, creating new Views allows you to apply specific Layouts and Extensions in order to make default content styling easy for your clients, customers or yourself.
Setting the View
To create a new View, all you need to do is go into the Views tab within your Builder theme’s Layouts & Views menu and click Add View.
There are lots of default page types you can apply Views to, including posts, pages, and home. You can even set Views to individual Authors or Categories.
After you’ve chosen the specific View you wish to change, you can select a Layout and/or Extension you wish to be applied to it. For instance, if you set the View as “Post” and the Layout as “Left Sidebar”, every post on your site would display the Left Sidebar Layout without the need to set it as the default layout for the whole site, or manually override the layout for each individual post.
To further illustrate the usefulness of using Views, lets take a look at how they can be used in conjunction with Categories. By default, you can set a View to effect all categories, but you can also assign specific views for posts with specific categories.
This can be an extremely useful option when creating a site for clients. You can create different Views that will automatically be applied for your client depending on the post category they use, possibly saving both you and your client from a lot of potential headaches and miscommunication later down the road.
Priority and Overriding Views
When using Layouts & Views, there is a basic hierarchy. At the lowest end of this hierarchy is the Default Layout set within the Layouts tab, which will be applied to all site content unless otherwise specified. Views are the second step in this hierarchy, and will override the default layout on any posts or pages that they target. Finally, a specifically set Custom Builder Layout designated at the bottom of a specific post or page will override the default layout or any associated views.
Pro-tip: Finding Which View a Page Uses
Not sure which View a specific page is using? Those who watched last week’s Builder 101 should already be familiar with this tip to help with identifying widget CSS classes, but it’s useful for identifying Views as well.
When you’re logged in as an administrator, you can right click anywhere on the page and click “View Page Source”. This will pop up a new window displaying your site’s source code. Scroll down a bit until you see a large comment block between the page’s closing head tag and opening body tag. This section contains lots of useful meta data about your page, but what we’re interested here is the line that starts with “Views”. This line will display the View the page you’re currently on is using.
The iThemes Codex provides much more information about Views, including a video overview and information pertaining to each supported type of View.