Drupal - Setting up ddblock

Using Dynamic display block (ddblock) to display highlights of content is incredible. The flexibility provided by this module is amazing and the setup/configuration is fairly simple. I'm going to break the setup down to the basics and walk you through setting up your first advanced ddblock. This tutorial is going to show you how to use ddblock to display content based on a content type utilizing CCK. There are other tutorials out there already outlining this, but I am going to compile mine with a few tips to hopefully prevent you from having some of the initial issues that I may have had.

CCK Modules First things first, we need to establish a basis of what is installed and what is required. Here is a list of items that should already be installed and setup. The image to the right shows the modules that are installed for CCK, Filefield, Imagefield and Views:

Drupal 6.x
CCK
Filefield
Imagefield
Views

The modules that you need to download to begin this tutorial are:

ddblock
jQuery Update

Copy the two new modules you downloaded into your preferred modules directory. You can either copy them to "sites/all/modules" or "sites/default/modules," based on where you have copied any other modules you have installed. Now, navigate in your browser to Administer -> Site Building -> Modules to install the new modules. Place a check in the box next to Dynamic Display Block listed in the Other Section and also place a check in the box next to jQuery Update listed in the User Interface section. To finish the installation, click the Save configuration button at the bottom of the page.

TIP: To utilize the import of a content type, ensure the CCK - Content Copy module is turned on. I will provide you with exports of everything possible, but I still recommend following along to make sure you know how the setup works. I also recommend following through with my configuration, using the same naming conventions for everything, and then once it is working go back and modify the setup to be specific to your site. To download the content type and view used in this tutorial, click here.

Now that the modules have been installed we can begin build the pieces to make them work.The first thing needed is a new content type to hold the information that will be displayed via the ddblock module. Navigate to Administer -> Content Management -> Content Types and click Add Content Type. We will name our new content type "News Item" and provide the machine name news_item, the description is not pertinent to this tutorial, so click Save content type. The next step to configuring the content type is to add some CCK fields to it. Click manage fields next to the News Item content type. We are going to add two fields to the News Item content type:

Label Field name Type of data Form element Notes
Pager Title pager_title Text Text field Click Add and then use all the defaults on the settings page.
Image image File Image Click Add and then if you want to change any of the path, file size, alt text, etc. settings you can.

TIP: If this content type is meant to hold true news stories, I would recommend utilizing a field as a flag. The flag would be set to make this particular news item into a ddblock. From personal experience, I know that not every news story will have an image.

Before we can configure more for the ddblock setup, we will need to create some news items. Navigate to Create content -> News Item to begin adding a news item. Be sure to provide each news item with a Title, Description, Pager Title, and Image. Create four news items so that we will have some data to work with.

Alright, to keep things moving, the next step is to create a new View. Navigate to Administer -> Site Building -> Views and click on Add. We will use the name News_Items and use the view type of Node, click Save. Add a new display, type block, and provide the initial configuration as follows:

TIP: While creating the block view don't worry about Live Preview when it says *Display "Defaults" use fields but there are none defined for it or all are excluded. *Display "News Items Slideshow" uses fields but there are none defined for it or all are excluded, since we will be adding the fields to the view.

Section Option Setting Notes
Basic Settings Block Name News Items Slideshow
Basic Settings Block Title News Items Slideshow
Block Settings Admin News Items Slideshow
Fields Group - Node Node: Body
Fields Group - Node Node: Title
Fields Group - Content Content: Image (field_image) Make the Format = Image Linked to Node
Fields Group - Content Content: Page Title (field_pager_title
Filters Group - Node Node: Type This should be set equal to News Item

After all of the configuration has been completed, be sure to click Save to keep the view. When setting this up for production, you can add additional fields, filters, and sorting to get the exact data that you would like to display.

TIP: If you have a WYSIWYG editor installed on your site, you will definitely want to make sure it is not being used on any of the screens in the configuration of ddblock.

We are now ready to begin the configuration of ddblock. Navigate to Administer -> Site Configuration -> Dynamic display block to begin the final stages of our setup. Click on the Settings tab on the main Dynamic display block setup page. Place a check mark in the box next to News Item in the content type section and a check mark in the box next to views - News Items Slideshow in the blocks section, click Save configuration. Now, click on the Instances tab to add this view as a ddblock. Type "ddblock - News Items Slideshow" in the Instance Title box and choose the "view - News Items Slideshow" option in the Block Type dropdown box, click Add Instance.

Prior to configuring the new instance of ddblock that was just added, we need to install a theme for ddblock to use. Download the theme for this tutorial by clicking here. You will want to copy the custom folder and all of it's contents into the root of your theme directory that your site is using. You also need to modify your template.php file for the theme of your site. The functions you will want to add to your template.php can be downloaded from here. Copy the two functions from the file template_functions.txt and add them to the very bottom of your template.php file. You will need to replace "[THEME_NAME]" with the name of your theme. So, if you are using the Garland theme, you will replace [THEME_NAME] with garland. If you do not have a template.php file included with your theme, there is a template.php file located in the download that can be copied to your theme. You will still replace [THEME_NAME] with the name of your theme.

TIP: After updating the template.php file of your theme, run the update.php script located on the Administer -> Site Building -> Modules page. If you don't run the update.php script the functions may not be executed and ddblock will not work.

Now that we have a ddblock instance and a theme installed, we are ready to begin configuring the instance. Click on the List tab in the Dynamic display block setup screen and the instance we just added should be shown. Click on the Configure block link next to the "ddblock - News Items Slideshow" instance. I am only going to provide you with the options that I am changing and everything else is left as the default option chosen. The following options should be configured:

Display Method = Cycleblock
Use advanced settings = Checked
Template = Upright10
Dynamic display block settings: Next = Unchecked
Dynamic display block settings: Use Pager = Checked
Dynamic display block settings: Pager Position = Bottom

Click the Save button to keep all of the configuration options.

You can set the permissions of who can view ddblocks by visiting the page at Administer -> User Management -> Permissions. On this page, there is a permission for "view dynamic display blocks." If you want anonymous users to view ddblocks, you will need to provide them with this permission. After giving them permission to view ddblock, you can still control individual block access from within the block module.

Everything is setup for ddblock, the only thing left is to turn the block on. Navigate to Administer -> Site Building -> Blocks and place the "ddblock - News Items Slideshow" into a region and save the blocks page. You should now see the ddblock you created if you navigate to any page using the theme that has that block turned on.

If you have questions/issues, post them and I will respond to them and update the tutorial to reflect issues so future readers don't run into the same problems.

This tutorial can be summed up into the simple steps of:

Install ddblock and jquery
Setup new content type
Populate content into the new content type
Create a block view for the new content
Add the new instance of the view to ddblock
Setup the template.php file with two ddblock functions
Install a theme for ddblock
Configure the new instance of ddblock
Turn the block on in the blocks page

*** Additional information about ddblock can be found on Dynamic display block slideshow module for Drupal web site. ***