Categories
Development

Drupal 7 Repeating Date Show Only Once in Views

This one had me scratching my head for a little bit. I had some events in Drupal and was using the fine Date module and had a few with repeating dates. I was able to display the repeating dates just fine, but was getting numerous entries displaying of the event itself.

Not 1 event with the various repeating dates being displayed.

After much head scratching and some digging around I found a solution.

I added a filter of Date (delta) and set equal to 0. So now I’m only grabbing on event instance.

 

Categories
Development

Display a Field Image Outside of the Content Region in Drupal 7 Using Views

I had a project where they wanted a big header image to appear on some of the content pages, above the content. I knew this wouldn’t be too difficult to do, but I was a bit initially stumped as to how best to do it using Drupal 7. I didn’t want to have to install too many modules for it to work, so I decided to start with Views as that module would be installed on the site anyway (of course).

Turns out this is pretty easy to do using Views.

  • First I added an Image field to my Content Type. Then I set the display to Hidden for that field. Easy basic Drupal Content Types stuff so far. Nothing fancy.
  • Then I created a View. A block in this case, and had it display the image field I had created.
  • Under Advanced, I clicked on Contextual Filters. From the list, I chose Content (Nid). I want to filter out by the node id of the current page being viewed. Simple still.
  • Next under the contextual filter options under the When the Filter Value is Not Available  I chose Provide a Default Value and Content ID from the URL from the drop down options.

This simply gets the Content ID from the URL of the current page you are on and then passes it to the filter.

Very easy to setup and works just fine for me!