Jul 09 2011
Jul 09
Printer-friendly versionPDF version

This is a short preview from my forthcoming e-book Building Your Blog With Drupal 7. There are two sections previewed here.

  1. Getting Your Blog Posts Onto The Front Page - I explain how to create a simple page, RSS feed and block using the new Views 3 interface.
  2. Arranging Sidebar Blocks - I explain how you can place the block you created in the previous section into the sidebar of your page.

Getting Your Blogs Posts Onto The Front Page

The next things you’re going to do are to set up a “view” (which is basically a list) for your blog posts and make that view the front page of your site. It’s true that there are simpler ways to do this, namely clicking the Promoted to front page checkbox in the add content window, but Views is so integral to Drupal that I think you should get started using it sooner rather than later.

To get started click on the Structure link in the admin menu, then select the Views link which should be the last one in the Structure window. At the very top of the next window you will see an Add new view link. When you click that link you should see a window that looks like the image below.

Add new view

There are a lot of choices to make when adding a new view so I’ll make it easy for you and show you the choices I have made in the image below.

You’re free to change any of the details to suit your own needs. The most important thing to understand is that these choices will result in the following features.

  1. A list of blog posts with the newest blog post displayed at the top
  2. A dedicated page at yourblog.com/blog that shows ten teaser (or summary) posts that include the title, the beginning of the body field and a link to the full post
  3. A dedicated RSS feed that people can use to subscribe to the blog in an RSS reader
  4. A block that you can place in the sidebar that has links to the five most recent posts

Once you have filled in your choices click the Save and exit button to complete the creation of your feed. The screen will refresh and you’ll be looking at the new page you created at yourblog.com/blog. You should see the “Hello World” post you created and an orange RSS feed icon that links to the blog feed. Now that the view for your blog has been created the next thing you want to do is make that view the front page of your site.

Click on Configuration in the admin menu then select the Site information link. The second section from the top of the site information page is called “Front Page”. Change the “Default front page” field from “node” to “blog” or whatever path you gave to your blog post view. Click Save configuration then navigate to your site home page. The front page of your site should now look something like the image below.

front page

Besides your blog posts the blocks to the left side of your posts are another important element of your site. The block you see on the top is the standard search block. I’ll have you leave that in place. The next blog down is the navigation block which we really don’t need since we have the administration bars at the top of the page. In the next section I will show you how to remove that block and add other blocks that you do need.

Arranging Sidebar Blocks

Click on Structure in the admin menu and then select the Blocks link which is the first link. You will see a table that looks like the one in the image below. Focus on the “Sidebar first” section of the table.

block administration

Click on the list box in the Navigation row and set the value to “-None-“. You’ll notice that Navigation disappears from the row. Scroll down to the very bottom of the page and drag the row called “blog_posts: Block” to the space below the Search form field. Then navigate to the bottom of the page and click the Save blocks button. Navigate to the home page and you will now see the Recent Posts block below the Search block.

If you like you can also add a Recent Comments block to the sidebar. The Drupal core comments module has created this block for you. Just go to the block administration window and drag “Recent Comments” to the appropriate position or select “Sidebar first” from the list box in the Recent Comments row. Keep in mind that those changes are not saved until you select the Save blocks button.

The final block that I’ll have you place for now is the block that will hold your tag (or category) “cloud”. In the Block administration window look for “Tags in Tags” and move that to Sidebar first then save your blocks. If you go to the home page it should now look something like the image below.

 home page blocks

You’ll notice that the “Tags in Tags” block has a dotted line around it with a configuration icon in the upper right portion of the block. The ability to go to the edit views of blocks directly from the block itself is a nifty new feature in Drupal 7. You should see something like that when you put your cursor directly over the block and point to the configuration icon. For all blocks you have the option of editing the title, the access levels and even the pages that they appear on. Tags in Tags happens to be a block that has an additional configuration option. You can edit the number of tags that appear in the block.

If you click on the configure block link that appears when you mouse over the configuration icon you will be taken to the block edit window where, among other things, you can adjust the block title to something like “Topics” and also change the number of tags that will be displayed if you like. Remember to click the Save button at the bottom of the window. Once you do that you will be returned to the home page of your site.

One thing you may have noticed when looking at your block configuration is the fact that the User login block is placed in the Sidebar first section. If you don’t want anonymous users to see that blog you should remove it just like you removed the Navigation block. You can always reach the login page of your site by navigating to /user/login.

I hope that you enjoyed this short preview. I have most of the content in the e-book finished. Once the content is complete I will be working on perfecting the formatting and cleaning up errors that I find along the way. If you want to be among the first to know when the e-book is finished then I suggest that you do one of three things if you haven't already.

  1. Subscribe to posts via the main Learn By The Drop RSS feed
Video Links

YouTube Version

Flash Version

Quicktime Version

May 23 2011
May 23
Printer-friendly versionPDF version

There are many new features in Drupal 7. For many one of the most notable enhancements will be the changes to the Views module. First of all, in Drupal 7 Views requires the Chaos Tools Suite in order to function properly. There are also changes to the process of creating views and to the interface. I have spent a little time working with Views on D7 and I think that the changes are a nice step forward in terms of usability.

As you can see in the image below when you create a new view you are presented with a host of very basic options that allow you to create a basic view very fast. For the example I set it up to display a page that lists links to the Page content type. I have also chosen to create a block along with the page view.

 Views in Drupal 7

You can choose to either save the view as you created it (by selecting the Save & exit button) or you can continue to add further customization to the view (by selecting the Continue & edit button). Of course, you can always come back and edit things later. You can see what the customization screen looks like below. You''ll notice that there is now an option to clone a particular display in the upper right hand portion of the screen. There is also a nice preview pane at the bottom.

Customizing Views in Drupal 7

Note: Click to view the full size image.

I am still in the early stages of utilizing the new Views interface and features. So far I like it and think that that the new screen that you see when first adding a new view will help less experienced users of Drupal to get started very quickly. What do you think of this new approach to Views in Drupal 7?

Video Links

YouTube Version

Flash Version

Quicktime Version

Nov 21 2010
Nov 21

This video tutorial shows you how you can utilize filters to limit the content that is displayed in a view. This includes how to expose a filter so that your site visitors can filter the content as well. 

Note: Click the 'full screen' icon (to the right of the volume control) in order to watch online at full 1280x720 resolution.

Video Links
Jul 24 2010
Jul 24
Printer-friendly versionPDF version

If you're like most people who build using Drupal you want to build your site around nodes, that have titles, descriptions, tags, comments, etc. It's no surprise since those types of content oriented sites are the ones that make the world of the web go round. But what about another type of site that focuses not on nodes but on data contained in the Drupal database? Can you do it? Yes. Should you do it? Only if that sort of thing excites you or perhaps if a client requests it.

I'll give you a little background on where I'm coming from and what made me decide to play around with Drupal as a way to expose data sets. About a decade ago I was part of a group of people who built a first of its kind application to send and receive data from wholesale power markets in North America. The application was built on three tiers: a client, an application server, and a database server. The client and application server were written in Java and the database relied on Oracle technology. It was about as far away from open source as you could get. The product was successful though and we did hundreds of installs all across North America. What the product basically did for its owners was suck in data from a central server then expose that data to the user via tables and charts visible from the user interface. At some point last year I started wondering if I could do something similar with Drupal. So I started investigating, tried out different modules and realized that I could do even more with a Drupal install than we did with that product.

There are four tasks that need to be accomplished if you want to use Drupal as an effective data platform.

  1. Capture data to the Drupal database tables
  2. Setting the data types (text, numeric, etc.)
  3. Expose the data to the user using tables and charts
  4. Offer simplified download format options

 Capturing Data

I have been capturing data using the Table Wizard module. Table Wizard allows you to create a database table by uploading a delimited (like tab or comma separated) file. This works pretty well. I recently uploaded a file with over 300,000 records and it was in the database within a few minutes. After you upload your file you click on the table name to "analyze" the table. Table Wizard will let you know what columns you have in the table, the data types and identify the primary key. When you first upload your data you will want to go switch over to your database to change data types of the appropriate ones and identify a primary key. Once you have done that you can come back and re-analyze the table. 

Setting the Data Types

This is probably the step that will be the least welcome to those who are not familiar with databases. If you want to do extensive work with data in Drupal then you will want to become familiar enough with phpMyAdmin and MySQL data types to be able to navigate to your database and apply the appropriate settings for each type of data. You should also indicate which field contains the primary key for the table. The primary key is a unique value that identifies each record in a table. If you have a dataset that does not have a column with unique values then consider adding a column unique numeric code in each row. You can name the column something like record_id and then add values like 100001, 100002, 100003 and so on.

Expose the Data Using Tables and Charts

If you have been a good boy or girl and added a single field primary key then the Table Wizard module will let you check a box that is labeled, "Provide default view." This option automatically creates a view that you can expand upon as you see fit. Auto created table wizard views will have the tag "tw" added to them. You can also create a view by navigating to /build/views/add and looking for the radio button in the 'View Type' section that starts with Database table. At this point you need to a thing or two about the Views module to go further. There's not enough space to cover that here so I'm going to skip over the details and point you to the key modules and settings.

The standard views module will let you create a table from your data. You just have to choose a Page display and choose the Table style. You can then choose your fields which will appear as columns within the table. Give the page a Path and perhaps add an Exposed Filter or two to allow users to narrow down the data they are looking at. If you want to get a little fancy you can choose use Views Calc to create tables that include calculations like min, max or average on a set of numeric data.

Charts are a little more tricky but it can be done with the assistance of Charts and Graphs and Views Charts. Charts and Graphs allows you to integrate a number of different free charting solutions (including Google Charts) into your site. View Charts makes those features available as a Style (called "Charts") within the Views interface. The chart gets exposed on a page based on the Path that you define. You can also create a chart within the Block display type. There are other charting modules that exist for Drupal. All of them have some drawbacks but so far the Charts and Graphs/Views Charts combo has worked the best for me.

Offering A Download Option

The ability to download data probably won't be a must have feature for every site. After all someone could probably just copy the table and paste it into their favorite spreadsheet program. It's a nice feature to offer though and you can do it pretty easily with the help of the Views Bonus Pack module. With Views Bonus Pack installed you get the option to add a Feed display within the Views interface. With the Feed display selected you then get the option of setting a Style that includes the option for CSV and other popular formats like TXT, DOC, XLS and XML. You can then attach that display to the Table display and there will be an image that appears at the bottom of the table page that will generate a file download when clicked. Be sure to add the same filters to the CSV display that you have added to the Table display so the downloaded file reflects what the user is seeing with any filters selected. 

The usual caveats apply to the ideas and tips that I've offered here. At any time a better module could come along or an existing module could change and alter the process a bit. So tread lightly and do some exploration before you commit to building a data driven site using Drupal. In fact, even though there was a very recent release of Table Wizard the development is being deprecated in favor of the Data module. I'll continue to upload using Table Wizard for now since I think it works well but also plan on giving the Data module a shot in the near future. 

As always I'd love to hear your thoughts and tips on modules and workflows in the comments. If you have built or know of a good data access website built using Drupal feel free to share those links as well.

Video Links

YouTube Version

Flash Version

Quicktime Version

Jun 29 2010
Jun 29
Printer-friendly versionPDF version

Recently I had to plan the unenviable task of adding terms from a new taxonomy category to dozens of nodes that had previously been created on a site. As I pondered my options (including a temporary Caribbean vacation) I remembered module I had seen pop up on Drupal.org called Views Bulk Operations or VBO for short. 

What VBO allows you to do create a view that will apply an action to many nodes at one time. So you must have the Views module installed and it helps to know your way around views a little bit because after installing and enabling VBO you'll need to create a Node view that will allow you to create a list of the nodes that you want to apply actions to.

The view that I created to make the taxonomy updates to the nodes in question had a pair of fields that allowed me to identify the nodes to update. Those fields for Title and Type, as in node type. This was just enough info to know for sure whether or not I wanted to make a change to the node. I added to the view a couple of exposed filters that would allow me to narrow down the list of the nodes by selecting the node type and a string of text from the title. The image below shows you what the finished product looks like.

So with this layout using exposed filters I can then make a couple of choices to filter the list down to the nodes I want to change. Then in the actions to take section I can indicate what I want to do by selecting the appropriate radio button. Then I can select one or more of the vocabularies in order to make that change. In my case I had added a whole new vocabulary with new terms so I chose Add the selected terms and then selected the vocabulary term that I wanted to apply (in this case from the Node Type vocabulary) before selecting the nodes (either one by one or by clicking the box next to Title to select all) then clicking the button (not shown in the image) at the bottom of the page to apply the update. At the end of the process you should see a confirmation that the nodes were updated. At that point you should double check a few of the nodes to make sure the updates were applied as you intended them.

Here's a little more about how I got to the end described above. The image below shows where you would select the style of Bulk Operations which is required for your view to offer you the correct options. Take note that the type of display you're looking for is one of Page. One more important thing to notice is the Access setting. Since this is the kind of function you would only want available to special users make sure you have Access set in a way that limits the ability to get to the page. In my case the user must have the permission to administer content types.


The image below shows the many options for the Bulk Operations style choice. Notice that I chose Modify node taxonomy terms as the only option. I don't know enough about the module yet to choose multiple options at once so I just stuck with the one.

The image below is what the preview looked like before I saved and attempted to use the view for the first time. Take note once again of the three elements. 

  1. Exposed filters which allowed me to narrow down the list of nodes
  2. The actions to take which should be consistent with my Bulk Operations settings choices
  3. The fields, Title and Type, which allow me to identify whether or not these are the correct nodes to take action on

Okay, so now you're ready to do some damage (in a good way of course) and make big changes to your nodes in a very short period of time. A final word of caution though. I did all of this on a pre-production site so if I did make a mistake it wouldn't affect site users. If you are trying VBO out for the first time I recommend doing so on a test site so that you can get the hang of what you need to do without having to back out major changes. Of course, if you make the wrong changes using VBO you can always back those changes out....using VBO.

Video Links

YouTube Version

Flash Version

Quicktime Version

Feb 28 2010
Feb 28

The Nodequeue module is an incredibly useful module that allows you select individual nodes and place them in a list in whatever order you like. This lesson shows you how to create a new nodequeue, add nodes to the queue, arrange the queue and then add the queue to a view.

Note: Click the 'full screen' icon (to the left of the volume control) in order to watch online at full 1280x720 resolution.

Video Links

Flash Version

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web