34,79 €
Integrating images, video, and audio content on a Drupal site requires knowledge of appropriate community modules, and an understanding of how to configure and connect them properly. With the power of up-to-date technologies such as HTML5, responsive web design, and the best modules available in Drupal's eco-system, we can create the best Drupal 7 media website.
Drupal 7 Media is a practical, hands-on guide that will introduce you to the basic structure of a Drupal site and guide you through the integration of images, videos, and audio content. Learn to leverage the most suitable community modules and up-to-date technology such as HTML5 to offer a great user experience through rich media content.
The book begins with a practical introduction to the basic Drupal building blocks. It then breaks down each media resource, and explores them in detail.
You will learn how to leverage Drupal's community modules to implement support for images, videos, and audio content, along with the best practices for implementation. We will be mentioning ideas throughout the book, which you can extend upon and use to build your own web applications. We will explore HTML5 support for media resources, the semantic web, and responsive web design, which are key topics in modern web application development. We will then build upon this knowledge and add more functionality to our sample website, such as support for analytic charts and customizing images, all of which we will implement using our own custom modules.
You will learn everything you need to know about building, extending, and configuring a Drupal 7 media web application.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 276
Veröffentlichungsjahr: 2013
Copyright © 2013 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: July 2013
Production Reference: 1180713
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-84951-608-2
www.packtpub.com
Cover Image by Erol Staveley (<[email protected]>)
Author
Liran Tal
Reviewers
Srikanth AD
David Madar
Grigory Naumovets
Michael J. Ross
J.G Sivaji
Janez Urevc
Acquisition Editor
Joanne Fitzpatrick
Lead Technical Editor
Sweny Sukumaran
Technical Editors
Joyslita D'Souza
Mausam Kothari
Sampreshita Maheshwari
Menza Mathew
Zafeer Rais
Project Coordinator
Arshad Sopariwala
Proofreader
Amy Guest
Indexer
Hemangini Bari
Graphics
Abhinash Sahu
Production Coordinator
Shantanu Zagade
Cover Work
Shantanu Zagade
Liran Tal is a leading software developer, an expert Linux engineer, and an avid supporter of the open source movement. In 2007, he redefined the network RADIUS management by establishing daloRADIUS, a world-recognized and industry-leading open source project.
Liran currently works at HP Software, leading the development team on a Drupal-based collaboration platform in HP's Live Network R&D group.
At HPLN, Liran plays a key role in system architecture design, shaping the technology strategy from planning and development to deployment and maintenance in HP's IaaS cloud. Acting as the technological focal point, he loves mentoring his team mates, providing a drive for better code methodology and seekout innovative solutions to support business strategies.
He graduated cum laude in his Bachelor of Business and Information Systems Analysis studies and enjoys spending time with his beloved wife and soul mate Tal, playing his guitar, hacking all things Linux, and continuously experimenting and contributing to open source projects.
Srikanth AD is a web developer who is passionate about developing and optimizing websites for better user experience and search engine visibility. He is particularly interested in adapting content management systems for developing structured and scalable websites.
Check out his portfolio at http://srikanth.me. Or feel free to get in touch with him on Twitter @Srikanth_AD.
David Madar is addicted to technology, which has also caught up his family. He has came from the mainframe systems, working many years in banking organizations.
He has over ten years of work experience in developing web applications and websites, as freelancer and as an employee in the leading companies.
He is currently employed at HP Software.
Grigory Naumovets lives in Kiev, Ukraine. His background includes a Ph.D. in Physics and Mathematics. Since 1996, he has been working as an IT consultant, an IT specialist, and an ICT coordinator for several international projects, and then also as a freelance web developer and webmaster. After trying several web content management systems, he started using Drupal CMS in 2007. Since then, he has developed, maintained, and supported a number of monolingual and multilingual websites powered by Drupal 5, 6, and 7. He takes an active part in the community of Ukrainian Drupalers.
Michael J. Ross creates custom websites for businesses and nonprofits, using Drupal and other leading web technologies. In addition, he writes technical articles and book reviews, of which more than 530 have been published in print and online. For this particular book, he did not perform copyediting, but instead provided input on its usage of Drupal. This is the fourth Drupal book for which he has done technical reviewing. Anyone in need of a new website can contact Michael at www.ross.ws.
I would like to thank my mom and dad, who have always been supportive of my personal and professional efforts.
J.G Sivaji graduated from college in the year 2009. He holds a bachelor's degree in Computer Science Engineering from Jaya Engineering College (affiliated to Anna University). He gave a start to his technical evangelism as a Google Summer of Code student in 2009. He worked on the Drupal quiz module to improve its features and fixed several bugs along with other developers. Since then he has been an active member, contributor to the community in terms of writing patches to core and maintaining contributed modules. Currently, he is playing the role of Technical Director at KnackForge.
A technical enthusiast and one among the group of directors and founders of an exciting Drupal startup, KnackForge Soft Solutions Pvt., Ltd., Sivaji's prime role is not only confined to be the Lead of the Drupal team, Chennai branch, but also to hold the accountability for customer relationship and internal quality management.
Sivaji has contributed to a couple of books published by Packt Publishing as a technical reviewer. The list includes Drupal 7 Module Development, Drupal 7 Themes book, and this book, Drupal 7 Media.
I would like to thank my colleagues at KnackForge for motivating, realizing, and helping me to bring out the best in me.
Janez Urevc is a Drupal engineer from Slovenia, EU. He has dedicated his life to free software and open source since high school. He graduated in the field of software development in the faculty of Computer and Information Sciences at University of Ljubljana. The topic of his bachelor thesis was implementation of Scrum methodology in a web development department of a bigger media company. He has been an active contributor to Drupal for a few years. He contributed to various contrib modules and Drupal 8 core (full list of his contributions can be found on http://drupal.org/user/744628).
Besides Drupal, he's passionate about almost everything connected to web, free software, Linux, and software development. He participated in Google Summer of code, 2011 and was a mentor in 2012. He is currently working at Examiner.com, probably the biggest Drupal site on the entire Web. In the past he worked for Delo, Slovenia's biggest daily newspaper, where he led development of a few of the biggest Drupal sites in the region.
He maintains a blog at http://janezurevc.name, where he writes about his work and life.
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
To my father, Eli Tal, who set me on this path.
"Thank you for the inspiration, thank you for the smiles
All the unconditional love that carried me for miles
It carried me for miles
But most of all thank you for my life"
Integrating images, video, and audio content on a Drupal site requires knowledge of appropriate community modules, and an understanding of how to configure and connect them properly. With the power of up-to-date technologies such as HTML5, responsive web design, and the best modules available in Drupal's ecosystem, we can create the best Drupal 7 media website.
Drupal 7 Media is a practical, hands-on guide that will introduce you to the basic structure of a Drupal site and guide you through the integration of images, videos, and audio content. Learn to leverage the most suitable community modules and up-to-date technology such as HTML5 to offer a great user experience through rich media content.
Chapter 1, Drupal's Building Blocks, serves as an introduction to the building blocks of Drupal's node structure. Starting with a bit of Drupal's history, we move on to Drupal's very basic and prominent node structure. You will be introduced to Drupal's administrator user interface, which will help you create your own Memo content type.
Chapter 2, Views, Blocks, and Themes, shows how to display content with the use of the Views module user interface, which enables us to create content listing quite easily. We then move on to the presentation layer of Drupal and learn how to create and position content elements (blocks) in the various positions (regions).
Chapter 3, Working with Images, dives into deep water and helps in creating our very own content type for a food recipe website. We learn about the prominent Media module and its extensive support for media resources such as providing a media library, and key integration with other modules such as the Media Gallery. We also discover the concept of text format profiles and the use of WYSIWYG editors.
Chapter 4, HTML5 in Drupal, covers the HTML5 spec, why the Web needs it, and how to make use of the spec to create cross-browser-compliant HTML code in Drupal. We also learn about the canvas feature of HTML5, and create a signature management web application.
Chapter 5, Video Capabilities, explores the myriad of options available to add videos media to our website. We will learn about integrating with third-party video hosting websites such as YouTube, and create a YouTube-like video sharing platform.
Chapter 6, Audio Capabilities, covers different ways of working with audio content. You will learn how to customize an audio presentation, utilize the abundance of metadata that is potentially stored in audio media, and tie it up with Drupal's content structure.
Chapter 7, Leveraging Other HTML5 Features, starts off by showing you how to enable RDF support in our Drupal's website. We also learn how to implement a graphical chart with the help of the Views user interface and custom code. We also touch upon advanced theming and responsive web design.
Chapter 8, Enhancing Media Content, reviews Drupal's media configuration and tools, which aid a site builder in enhancing media-related content. You will learn how to apply image manipulations and how to build your own effects. You will explore the use of Colorbox and Plupload modules. Finally, you will learn about the rating module that adds voting capabilities.
Chapter 9, Drupal 8 and Beyond, reviews the upcoming Drupal 8 release and the changes it is introducing. Many of these changes are architecture and software design related changes, such as configuration management, core framework refactoring, better layout, and general mobile-ready with built-in support for HTML5.
Drupal 7 requires PHP 5.2.5 or higher to run the Drupal code. You will also need one of the following databases to run Drupal 7:
You can use Apache HTTP, Nginx, or Microsoft IIS for the web server.
We recommend you to use a GNU/Linux, Apache, MySQL, and PHP setup, also known as LAMP, for best performance and community support.
If you are a Drupal site builder and you wish to spice up your web applications with rich media content, then this book is for you. A basic understanding of HTML, JavaScript, and basic PHP module development in Drupal would be helpful, but is not necessary.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <[email protected]>, and mention the book title via the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the erratasubmissionform link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.
Drupal is a free (licensed under the General Public License (GNU), Version 2 or later), community-powered, open-source Content Management System (CMS), which allows creating websites of many types. It's a great tool for both, users with no technical background, as well as top-notch developers, to use it for building complex websites and web applications.
Some examples for popular companies and organizations that decided to leverage Drupal as their content management system are FedEx, Symantec, MTV, and Duke University. The list is long, and you can find out more at http://drupal.org/case-studies or http://www.drupalshowcase.com.
In this chapter, we will cover:
Drupal began back in 1999 with Dries Buytaert starting to develop his idea for a forum platform, and has greatly evolved into a leading and award-winning software. Since then, it has seen significant growth. Today, it powers millions of websites and has positioned itself as a candidate at the top of the list for websites and web platform frameworks. Drupal has a company behind it, Acquia, which drives for further cutting-edge development, keeping the pace with the technology trends, and serves as a commercial resource for those requiring professional services.
With almost every release, Drupal has managed to reinvent itself, for both its developer community as well as its users. With Drupal 7, it has even more transformed itself into a Content Management Framework (CMF), by providing many abstractions to what content is and how it is handled. This road is setting the path for a large adoption by developers, to create web applications in many verticals, and has spurred a variety of platform niches from enterprise software, e-learning, and e-commerce, to social networking and collaboration software, to name a few.
Drupal 7's technology stack requires PHP5 (5.2.5 or higher) for the application server; MySQL (5.0.15 or 5.1.30 or higher) as the more favorable option for a database server, and HTML/jQuery for its presentation layer. The choice for this technology has no doubt helped in making it popular and easily deployable for hosting companies.
Being a CMS, in Drupal, most of your website probably will be structured around content. Whether it's managing it or displaying it in different layouts, themes, and views, content will be driving your website. Even more, content may be associated with the business logic about your website, which then defines a behavior based on content. Some examples for that may be, to send an email notification to users when a new content has been created, or to assign a rating system to content, such as five star rating or kudos, so that users can like it and in turn, this content receives higher visibility among your users. The possibilities are endless.
You have probably understood by now that content is very much a generic term for anything. It can be an article or blog if you're planning to run an online news-magazine website, or it may be a message post limited to 140 characters (if you didn't recognize, that's Twitter basically). Content can even be the posting of images by users, aligned in vertical columns with an infinite scroll, or the posting of videos. Throw into that the ability to rate, tag, create a personalized feed, maybe a customized bookmark/playlist too, then some of that special sauce we call social networking, by adding friendships and following the activity of other users in the website, and you've got yourself what we know today as Pinterest and YouTube.
It's been a long time now that the term node has been at the very core of Drupal, so you have probably heard of it by now. As we've seen, content is very abstract and can take on many forms and shapes. Due to that reason, you'll often hear or read that "In Drupal, everything is a node" and that's most often the case. Whether your content is images, blogs, videos, forums, or polls, they all share very common characteristics and can be abstracted as a node.
These attributes of content such as title, body, created and modified time, whether the content may be commented on, and so on, are all pretty common properties across the different content types. And for this reason Drupal considers all these to be of the same nature, and so, to provide more flexibility without limiting the content types, it's simply called a node.
When examining specific content types in detail, it becomes clear that having a specific set of attributes such as Title and Body, is not enough. A Poll type content would require additional fields, such as text fields, which will represent possible answers. Download type content may require a file attachment field, in which a user can upload, and then another user can download. These additional fields have been developed as part of contributed modules, by the community, which answer this exact requirement of adding more fields and field types to nodes than what Drupal provides out of the box. You may have come to known these modules as Content Construction Kit (CCK) and Chaos Tools and many other modules which build upon this field's framework and further enrich content types. We will go into more details soon enough on this.
Out of the box, Drupal 7 ships with two basic content types: Article and Basic page.
The Article content typeis used for blogs or news item, and as such it features properties such as, a comments area enabled, fields such as images and tags, displaying of the latest added content of this type in the front page. A Basic Page on the other hand doesn't have the comments area display, nor any special fields. Its display doesn't contain any information about the author who created the page and when it was created, but rather just prints the body of the page. It's easier to see the distinction between the two content types, and designing your content type's fields and settings is a very important part of building a website with Drupal.
Nodes are Drupal's term for any-kind-of-content, but Drupal 7 has taken a further step in abstraction and possibly coined a new phrase "everything is an entity", when introducing the entity model.
A thought may have triggered in your head when reading about nodes that while many content types are similar, they are definitely not the same. Some may not even require what Drupal would consider as a core field such as a title. This would then result in redundant data and a schema structure that is not very fit for what you had in mind for your content type to be.
To take this further, much inspired from other Object Oriented Design (OOD) concepts, Drupal also figured that it's basic schema for users and other objects such as taxonomy, comments, and so on, may be lacking too, meaning that it may be too strict, and site builders will eventually want to customize and extend those. With this thinking in mind, it has been made clear that nodes are not the only objects to take the even more generalized form of entities. This will rather extend to users and more objects that Drupal has been making extensive use of, for a while now, as its core building block (taxonomy, users, and comments, to name a few).
You may ask yourself what's new about defining entities because if you required your own unique data structure you could easily design the schema for it in your module's install file and decide what fields you need to create the database table that fits your needs. If you choose to go this road then those table fields are almost entirely disconnected from Drupal's built-in hooks system, and you are left on your own to tie them into Drupal's handlers. With Drupal's entity model you get this Drupal-awareness connectivity for free and many aspects of Drupal can then interact with your entities.
Entities allow us to create a common infrastructure across different objects, such as nodes and users. Then, if nodes are able to define a content type such as an article and assign fields to it, this goes the same for the users. This generalization of objects to a common ground provides software developers better maintenance and interoperability, and in result we, site builders, gain more features and powerful tools to customize and create the website as we see fit.
Bundle is the name given for the implementation of an entity type. If we implemented a node entity (meaning, we create a content type) and called it article, assigned some fields to it too, we inherently created a bundle called article. Bundles allow for the grouping of different entity types with their respective fields.
Nodes are not gone nor have they been replaced. For most content types, where it makes sense to treat something as a content rather than an entity, should not be abused and one can definitely build on the node's generic structure design with the envisioned content type and its related fields.
Creating entities is a task which requires defining many properties of it, whether it's fieldable, its basic fields structure, and so on. Sometimes, one would need to create an entity type which Drupal doesn't provide out of the box, like nodes or users, this process is much regarded as "further customization achievable by program code", hence requiring more in-depth knowledge and technical skills, which we will not pursue in the scope of this book.
So far we've introduced the concept behind the entity model, and in specific, the nodes and their content types. Let's proceed by creating a new content type that we'll name Memo for keeping personal notes.
What's so special about creating digital "stick it" notes? Even the simplest ideas can grow into great applications that can affect our everyday life. Evernote (http://www.evernote.com), which dubbed itself as "remember everything from saving thoughts and ideas, to preserving experiences" is the company behind the popular mobile and web app, for creating and sharing (rich media) notes with your peers, and is valued at an amazing $1B price tag.
We assume a fresh install of Drupal 7 (7.19 is the version available at the time of writing this book) so the first page should probably look as follows:
When logged in as an administrator user you will see the administration navigation bar at the top in black color. We will often refer to this as the administrative navigation bar, mostly throughout this chapter, since we are just starting out. When otherwise navigation is being described, such as Structure | Contenttypes, it is always referring to the menu items from that administrative navigation bar at the top. For your convenience, we will also often note in parenthesis the direct URL to access the relevant page.
To create the content type we can either make use of the shortcuts present in the page content area (this is the center of the page) or the Navigation block (in the left side of the page). If you are unable to locate neither of these we can use the administrative navigation bar at the top and navigate to Structure | Content types | +Add content type (/admin/structure/types/add).
In the new content type page, we'll provide the content type name, Memo, and an optional description.
It's a better naming convention to use the singular word for a content type. As you can see, Drupal has already modified our title for its internal use, noted by the Machine name field.
More settings for this content type are available but we'll only customize the Title field name and call it Memo, leave the rest of the default options as they are, which basically are the same as Drupal's built-in Article content type which we described earlier.
Last, we will click on Save content type which saves the settings and submits the form.
At this point, we have our newly created content type Memo and we can test how it works. We want to add content to the newly created Memo content type, so we will either use the shortcut for Add content, or if they are not present we can use the top administrative bar and navigate to Content | Add content (/node/add).
In addition to Drupal's default content types we see our new Memo content type.
After choosing Memo, we will see the Add content form for creating our specific content type, where we will provide the memo title and a more descriptive body message.
Once finished with the memo we'll hit the Save button to submit and create our new memo.
Our memo has been submitted and for logged-in users, it looks as follows:
When looking at the preceding submitted memo, you may realize that there is room for improvements, such as, adding some images would have been more appealing to the eye. Also, it may be nice to have dedicated links field so that we can display them the way that we choose to, like a resources listing of them, at the bottom of the memo.
This brings us to our next topic in this chapter: Fields.
With fields, we can customize our content types to our pleasing, by adding select box dropdowns, file attachments, images, radio buttons, and more. Every content type may have different fields, and once a field has been created it can be used for other content types which greatly ease management of fields, for both the user as well as Drupal's inner working.