Drupal Learning Journal 19. A Book of Videos

There is an yet-unsolved bug in the Media module (for Drupal 7) that prevented us from making the video gallery of a site work that we ported from one host to another. The issue has been documented and discussed here, here, here and here. We couldn’t wait any longer so I worked out a relatively simple substitute. There were only a few features that I had to keep in mind when thinking of a different solution:

  1. Paging through one video to the next within a category was a must.
  2. Providing a title, tags and description of each video was also required.
  3. On the gallery page display I could use thumbnail images only, because embedding more than one YouTube video on a webpage might cause problems.
  4. The site doesn’t have a lot of videos: 18+4 in two categories, so at this point the solution didn’t have to be hugely scalable.

 

One of the main features of Drupal’s “books” content type is the ability of paging through content, so it was obvious that I had to create my first “book” for this video gallery to satisfy criteria #1. I learned two lessons in “writing” my first book:

  1. Any type of content can be made a page or top page/cover of a book, but you have to put it on the list of “Content types allowed in book outlines” at “/admin/content/book/settings”.
  2. Only published content can be made part of a book. My original plan for this video gallery was to set it all up of unpublished pages, get the client (who has admin rights on the site) to view and approve it and then build out the whole gallery. But I couldn’t do the unpublished beta as part of a “book” so I created the gallery at temporary/secret URL for the client’s approval. Once that happened I finished building the gallery (, unpublished the old one) and specified its URL to be the same as  the old, non-functioning gallery’s URL.

To make sure that criteria #2 is ideally handled I made a custom content type for the individual videos, imaginatively named “Videos”, with only the few fields needed: title, tag, description and I used the default” body” field for the HTML code of the YouTube/Vimeo embedding code. I had to pay to attention to two things with the code:

  1. Getting the correct code: The default code you get on YouTube when you click on the “embed” button under a video has changed recently to an “iframe” solution from the older “object/embed” method. The problem with the new system is that it is possible in some browsers to disable “iframes”, so those visitors who do that would not see the videos on our site. Fortunately the old method is still available, but you have to check the “Use old embed code” checkbox to get it. I also made sure that the other checkboxes are unchecked. (I just read the description of what the “Enable privacy-enhanced mode” checkbox does and in the future I will check that.)
  2. Posting the correct code: I made sure that the text format for the field on our site where I am pasting the code accepts the “object” tag. Otherwise after posting the code Drupal would simply strip it out as it does with every tag that is not explicitly listed as an acceptable one. The default text formats (Plain text and Safe HTML) do not allow the “object” tag as there is a possibility of malicious misuse, so I selected a different text format.

I could have used “Views” to make the main/top gallery page, but in this case it was faster and simpler to do a simple HTML table and paste it in “body” field of the book’s top page. Voila, the gallery is up and running. The only aspect I didn’t like about my solution that below the table of thumbnails is the list of book pages, therefore there is duplication of content. I could have created an appropriately modified tpl.php file, but that would take more time than avoiding this minor visual redundancy is worth. If there is another way to disable the listing of page son the top book page, please somebody let me know. I didn’t find it.

Leave Comment

Your email address will not be published. Required fields are marked *