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:
- Create a new "banner_ad" content type (published, not promotes, no post info, comments hidden, no menu) under Structure->Content Types
- 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.
- In the "Default" view under "Manage Display" move the image to the Hidden section.
- Create a banner ad using the new "Banner Ad content type you've just created.
- Call it "Main Banner Ad"
- Scroll down to the Image section and upload the banner ad image
- Click in the Body text entry field and then click "insert"
- Click on the image and click the "link button" and enter the Url, select the window and add the title text.
- Save the ad.
- Create a new View (Structure -> Views) called Banner Ads
- Uncheck "Create a page" and Check "Create a block"
- Change the block title to "Main Banner Ad"
- Change Display Format from Titles(linked) to fields
- Change Items per page to 1 and click Continue
- Change the Display Name to "Main Banner Ad" if not already set to that.
- Remove the title
- Add a Content:Body field to the Fields section and uncheck "Create a label"
- Save the Field
- Remove the Content:Title field
- Add two filters to the filter criteria:
- Content:Title should equal "Main Banner Ad"
- Content: Type should equal "Banner Ad"
- Change the "Use pager" setting to "Display a specified number of items" and set that to 1, starting at 0
- Save the view
- Open up Structure->Blocks and position the new block as required.
- 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