Drupal - Views Calendar Theme "Page by date" Navigation Title

I was using Views to display a calendar of events. I then attached a date navigation pager to the calendar. By default, the navigation title was coming out looking like this:

Build a Mobile App to Sell Products with Drupal

This tutorial describes how to create a website and mobile application to sell physical products. Customers on a desktop or laptop computer will be able to purchase the product through the website, much like a typical e-commerce store.

Once we have built the mobile application, customers who have downloaded and installed the mobile app onto their Android or iOS (iPhone, iPad) device will be able to purchase the product as an In-App Purchase.

For this example website and mobile app, we're going to sell bottles of beer. *Cough* - Please don't actually sell beer without first getting permission from your local Big Brother.

The main 3 sets of tools we will utilize are:

This tutorial was inspired by this Session from DrupalCon Austin 2014. If you're new to any of these tools mentioned above, please watch the video for an introduction. Otherwise, let's get started!

Drupal - Get a View's Export Code Programmatically from CTools

With Drupal and Views, we are able to configure a View's settings and import/export them across Drupal sites. This allows us to create backup copies of our View's settings and/or move a View between Drupal sites with relative ease.

Typically this is a manual process by using the Views UI to copy the "export" code string from one site:

..and then paste the string into the "import" form on another site:

Drupal - "Hooking" into the Deletion of a View

Today I stumbled upon the need to do something I've never done before in Drupal. I needed a hook to run some custom code when a View was deleted. First, I checked out the list of Views Hooks and didn't find any hooks that appeared to be able to get the job done.

After a bit of Googling and chatting in #drupal-support on IRC, I was directed to this old closed issue. From my understanding, the delete hook doesn't exist and it  sounds like it won't be existing anytime soon. What can we do? Well never fear, Drupal is here.

Drupal - Create a Menu Tab with Views for a Node Content Type

This article describes how to place a custom local task menu tab alongside the 'View' and 'Edit' tabs on a content type.

Drupal - Views RSS Feed Title Customization with Preprocess

Creating an RSS feed with Views in Drupal is easy as pie. You can add contextual arguments to your View to provide many different types of feeds. You can even set up custom titles based on the contextual filter arguments all without writing a line of code! Amazing.

Drupal - Alter Views Exposed Filter Form

With hook_form_alter, we can adjust a Views Exposed Filter Form. For example, I had an exposed filter so users could select a particular node reference to filter on. However, the exposed filter was including unpublished nodes, and I needed to get rid of them. So with a little code like this, we can get the job done:

Drupal - Views hook_views_query_alter Group By

So my story goes like this.... I was building a view which showed a slideshow of content. Due to some views' relationships and complex content types, we were getting duplicate results. No big deal? This happens from time to time, the views module doesn't rule the world, yet. So sometimes we can just adjust the views settings to use DISTINCT, and that will solve our problem, other times not. This was a time where DISTINCT didn't seem to be helping. Usually when this happens, I fall back to my good old friend, hook_views_query_alter().

Drupal - Render a View in a Node Template

In this example, we have a content type called Unit (machine name: unit). And we want to programatically render a view on its node template. So we'll do something like this:

1. Create a copy of our theme's default node.tpl.php file and save it as node--[type].tpl.php file in your sites/all/themes/my_theme directory. In this example, a file name of node--unit.tpl.php is correct.

2. Render the view into a theme variable.

Drupal 7 - How to Modify a Views Query with a Custom Module

To make custom alterations, changes, adjustments, etc to a Views query in Drupal 7, try this module (or add the code in the .module and files to your own custom module):

name = My Module
description = Behold my awesome module.
core = 7.x
package = Other



Subscribe to RSS - views