Tree House Interactive Agency

Blog posts tagged with 'views'

A Views handler, the easy way.

If you are like me, you have avoided diving into coding for the black hole that is Views. Every time I started to look at the mass amount of documentation, I went blind. There is no shortage of documentation and examples. Besides looking for how other modules have implemented Views, the following documentation is available.

Even with all of this documentation, something didn't quite click. Sure, I could do the easy stuff, like expose a new table to views or manipulate an existing view, but when it came it creating a custom handler, I was lost.

So today I'm sharing with you an example of a new custom handler. We had the need to create a modification of the taxonomy term filter that allowed for using multiple vocabularies. We also needed it to be in an exposed filter to be used in an administration screen.

Let's start by first looking at what is different, then at the current filter.

Comment Moderation: The finale - Putting it all together

This is the last post in a 4 part series about Views, Views Bulk Operations, Actions and Features. In the first post of the series I walked through the Views Bulk Operations module. In the second post, a high level plan was put into place for the comment moderation feature. We also created the action plan that we followed for the final two posts. In the third post, we implemented several parts of our action plan. This included the view, creating the feature and coding the actions.

This post will finish up the comment moderation feature. Below is the action list. The bold items are addressed in this post.

Create View with 2 page panes.

Creating a Canned Search With Views Exposed Filters

A client recently had a requirement for what we call a canned search.  A canned search is simply a saved search with specific criteria that can be accessed directly at a URL.  This allows content editors to easily generate a list of various types of content suited to a specific topic without having to specifically link the items together in another manner.

As you might have guessed, Views is the primary engine for this feature.  However, it also uses a couple of other capabilities of Views that demonstrates another side to its already amazing flexibility.   Exposed filters is a well-known feature of Views allows a user to modify search criteria on the fly so that everything does not have to be determined ahead of time when the view is created, but one other less well-known feature is the ability to display those exposed filters separately in a block.  These are the primary builing blocks of our canned search feature.

Comment Moderation: Part Two, adding the Actions

In my last post, I walked through the high level plan for the Comment Moderation feature. We came up with a summary of tasks. In this post we will be creating the views and actions. Below is the list of the tasks, bolded tasks are being tackled today.
Create View with 2 page panes.

Comment Moderation: Part One

In the last post, I walked through the Views Bulk Operations module.  My initial plan was to write this post about actions, but  after researching how to best write about actions, I found a ton of detailed information about how to make an action. 

So instead of walking through Actions in detail, I'm going to walk you through plan for the comments moderation feature.  The next post will have the comment moderation actions and views, and the final post will discuss the integration with other modules.

Requirements for the comment moderation feature are:

Using VBO and Actions to manage your content – Part1: VBO

Did you ever find a Drupal feature that was so incredibly simple and easy to use that you were sure that everyone else already knew about it? Using Views Bulk Operations (VBO) together with Actions was one of the moments for me. Asking around to my fellow developers, I discovered that the use of the combination of VBO and Actions is common. In this blog series, I am going to walk you through using VBO and Actions to create some kick-ass administration forms. First we will look at the basic concepts around VBO and Actions, then I will show you 2 examples: comment administration and user administration. Both will be made available as a feature.

Part 1: Views Bulk Operations

Views Bulk Operations is a contributed module by kratib. There is a good general description of VBO on the project page:

Speed Up and Version Your Views

Since getting started with Drupal over two years ago, the sites I’ve built with it have naturally gotten bigger and bigger in scope. As your sites get bigger and bigger, you always look for ways to keep your site running as smoothly as possible, and this usually ends up meaning getting rid of queries wherever you can.

One feature of Views which is often used by module developers is the ability of a module to expose a set of default views. The calendar module, for example, provides a default calendar view in both its Drupal 5 and 6 versions. This is an obvious asset for developers of contributed modules: if your module interfaces with Views, it makes sense to provide a default view that users can modify.

Implementation and Potential Benefits

The hook used to do this is hook_views_default_views(). Since most modern sites are run off of a number of Views, you can also realize several benefits by building your sites with a custom module that implements hook_views_default_views():

  1. It improves performance. Views implemented via hook_views_default_views() do not require a database query to instantiate. You will realize an even greater performance gain if you also use an opcode caching system such as APC or XCache.
  2. Providing views in code will allow you to override the default view to make changes, and you can then choose to keep the changes in the database, update the module file to reflect the changes, or revert back to the version in your module file.
  3. Because the view (and theoretically, changes to that view) are stored in files, you can put them in version control and see how the views used in your site change over time and revert to an earlier version without having to go to a database backup.