Drupal 7 Banner Ad block Hack

Ok, so how do you add a simple single banner style ad block in Drupal 7. Here's my version

Module Requirements (these are assumed to be already configured):

  • Views
  • Insert
  • Wysiwyg
  • Colorbox (optional)

Directions:

  1. Create a new "banner_ad" content type (published, not promotes, no post info, comments hidden, no menu) under Structure->Content Types
  2. Under Manage Fields add a field named Image (existing field field_image) to the type. Make sure you "Enable the insert button" in the Insert section of the setup.
  3. In the "Default" view under "Manage Display" move the image to the Hidden section.
  4. Create a banner ad using the new "Banner Ad content type you've just created.
    1. Call it "Main Banner Ad"
    2. Scroll down to the Image section and upload the banner ad image
    3. Click in the Body text entry field and then click "insert"
    4. Click on the image and click the "link button" and enter the Url, select the window and add the title text.
    5. Save the ad.
  5. Create a new View (Structure -> Views) called Banner Ads
    1. Uncheck "Create a page" and Check "Create a block"
    2. Change the block title to "Main Banner Ad"
    3. Change Display Format from Titles(linked) to fields
    4. Change Items per page to 1 and click Continue
  6. Change the Display Name to "Main Banner Ad" if not already set to that.
  7. Remove the title
  8. Add a Content:Body field to the Fields section and uncheck "Create a label"
  9. Save the Field
  10. Remove the Content:Title field
  11. Add two filters to the filter criteria:
    1. Content:Title should equal "Main Banner Ad"
    2. Content: Type should equal "Banner Ad"
  12. Change the "Use pager" setting to "Display a specified number of items" and set that to 1, starting at 0
  13. Save the view
  14. Open up Structure->Blocks and position the new block as required.
  15. For other ads in different blocks, clone the block and change the content title as needed.

This is just a simple single image and is not intended to use multiple images or rotate banners. You can change the banner by unpublishing the banners and creating a new piece of content with the "Main Banner Ad" title.

Post new comment

  • Syntax highlight code surrounded by the {syntaxhighlighter SPEC}...{/syntaxhighlighter} tags, where SPEC is a Syntaxhighlighter options string or "class="OPTIONS" title="the title".
  • Lines and paragraphs break automatically.

More information about formatting options