Book Image

Flash with Drupal

Book Image

Flash with Drupal

Overview of this book

Due to its power and expandability, Drupal has become one of the most popular open source content management systems. At the same time, Flash has been adopted for its ability to create beautiful and dynamic web applications. By combining these technologies, you can create Flash applications that are both visually stunning and rich in content. This book is an in depth discussion and tutorial on how to integrate Flash applications with Drupal CMS. It will describe the best techniques and practices for integrating Flash technology with the power and flexibility of Drupal by building real-life Flash applications. Within this book, you will learn how to build Flash applications that show text from within Drupal and also present images, music, and video within a single Flash application. You will also be able to take advantage of the expandable fields and content filtering provided from the CCK and Views modules to add flexibility and power to your Flash applications. Finally, you will learn how to add your own custom functionality to Drupal and then utilize that from within your Flash applications leaving you with a world of possibilities. This book starts out with a simple introduction to Flash and Drupal technology where you will create a simple Flash application and then embed that within Drupal. From there, each subsequent chapter builds on the previous chapters tackling a new and challenging task. For each new task, you will take a step-by-step approach to building a real-life application that utilizes the feature introduced within that chapter. You will also explore alternative design approaches that will eliminate the current design challenges that developers face when building Flash-driven Drupal sites; and all this while staying true to the Object Oriented Principles that govern the foundation of the ActionScript 3 language. By the end of this book, you will be able to apply all the lessons learned from this book to any other use case you may encounter.
Table of Contents (17 chapters)
Flash with Drupal
Credits
About the Author
About the Reviewer
Preface

Getting started with Drupal


We will kick things off by first exploring Drupal and seeing how to utilize a few of its many features for our Flash applications. Although this will not be a complete guide to Drupal, it will give us a quick introduction, so that we can comfortably integrate its power into the Flash applications that we will create in this book. And, it all begins with the installation!

Installing Drupal

Since Drupal is a web-based application, our first goal is to install a server that will be able to run and execute the PHP code that makes up this incredible CMS. The most typical setup for running Drupal is to use an Apache web server along with PHP and MySQL services enabled.

Installing Apache-MySQL-PHP (AMP)

There are many ways to install Apache, MySQL, and PHP, but I would highly recommend installing a pre-built AMP package onto your computer, and then running Drupal on your machine through a local server. Luckily, there are several pre-built installers that make this step as simple as possible. Each operating system has its own version, and they all can be found at the following locations:

Each of these packages has an easy-to-follow installer that will install an AMP server on your local machine, so that we can then install Drupal. After we are done with the installation of these packages, we should be able to go to the following locations within your web browser, to see a welcome page.

  • Windows and Linux—http://localhost

  • Mac—http://localhost:8888/MAMP

If you are using MAMP, then I would highly recommend setting the default Apache and MySQL ports by clicking on the Preferences button in the MAMP application. Once you are in the Preferences section, we will then select the Ports tag and click on Set to default Apache and MySQL ports.

This will make it such that you can type http://localhost within your browser without the port (:8888), which is consistent with the rest of this book. Now, with a web server installed, our next step is to install Drupal.

Creating the Drupal database

Once we have our AMP server running, our next task is to create a database that we will use for our Drupal installation. This simply requires running phpMyAdmin that comes with the AMP packages, and can usually be found by navigating to the welcome screen at http://localhost (for XAMPP) and http://localhost/MAMP (for MAMP), and then clicking on the link that says phpMyAdmin. Once we are inside the phpMyAdmin front page, we can easily create a new database called drupal6 using the Create new database input field and clicking on the Create button.

Now that we have a new database, we will need to create a new user who can use our Drupal database.

Creating a database user

We will create a new user by first navigating back to the main phpMyAdmin screen, and then clicking on the link that says Privileges. Once we are in the Privileges section, we can create a new user by clicking on the Add a new user link. We will then fill out the user information by providing the following information (of course, you can use your own username):

Our next task is to make sure that we give our user the correct privileges to use the database that we just created. Since we are just using this as a local server, it is completely fine to give your new user global privileges by clicking on the Check All link that is next to the Global privileges section.

We can now click on the Go button, at the bottom right of the Privileges section, to create our new user. Our next step is to increase our PHP memory, so that Drupal does not timeout when it is installing.

Increasing PHP memory

This next step is almost always overlooked when installing Drupal. By default, the AMP packages do not allocate enough PHP memory required to install Drupal. Because of this, we will need to edit the php.ini file and manually increase this value. The php.ini file can be found within the conf/php5 directory of our AMP package installation directory. Once we open the php.ini file, we will perform a search for memory_limit and change it to 32M. While we are in this file, we should also probably increase the execution and input time as follows:

max_execution_time = 1000
max_input_time = 1000
memory_limit = 32M

After we save our changes, it is very important that we reset Apache so that these changes take effect. We can do this by opening up our AMP control application, and choosing to reset the Apache server, or we can simply close and restart this application to perform the required Apache restart. With this done, we are now ready to install Drupal!

Installing Drupal

Moving right along, we can download the latest version of Drupal by going to http://www.drupal.org and clicking on the download links found on the homepage. For this book, we will be using Drupal 6, so select the latest version of Drupal that begins with 6. At the time of writing, the release was version 6.10, which can be downloaded at http://ftp.drupal.org/files/projects/ drupal-6.10.tar.gz.

Once we have downloaded this package, the next step is to extract the contents into the document root of the web server. This is typically within the htdocs folder of the XAMPP or MAMP installation. Whatever resides in this folder is now visible when you navigate to http://localhost from your browser. For example, if we created an HTML file called index.html inside the htdocs folder, and then navigated to http://localhost, we would see that HTML file rendered within our browser as a web page. In this book, we will simply create a new folder within our htdocs called drupal6, and then extract the contents of the Drupal 6 package inside that new folder. Since we have placed all of our contents inside the htdocs/drupal6 folder, we can now open up our browser and type http://localhost/drupal6 to see the following:

We can begin our installation by clicking on the link that says Install Drupal in English, where we will then be greeted with the following page:

Don't let the red scare you. What this is telling us to do is find the default.settings.php file within the sites/default folder of our extracted Drupal folder. Once we find this file, we simply need to rename it as settings.php. After it has been renamed, we need to change the permissions of the file so that it is writable. When we are done, we can click on the try again link, and see the following:

From here, we will just enter all the database information that we set up in the previous section, and then click on the Save and continue button. This should then walk through the installation process. If it does not, then we can manually edit the settings.php file and manually put in our database information by changing the following line:

$db_url = 'mysql://travist:mypassword@localhost/drupal6';

We can now navigate to http://localhost/drupal6/install.php and kick off the installation. If all goes well, we should see the following page:

At this point, we can fill out all of the initial configurations for our Drupal web site, including the site name, email, user name, password, and so on. When we are done, we can click on the Save and Continue button at the bottom of the page, where we should see the following:

When we click on the link that says your new site, we should then be greeted with the most popular Drupal page (as shown in the following screenshot).

With Drupal installed, we will now add some content.

Adding content to Drupal

In order to build a Flash application that utilizes Drupal content, we will first need to understand how to add content to Drupal. Fortunately, this step is very simple and first requires us to click on the link that says Create content on the left navigation menu. Once we click on this menu item, we should be given an option to either create a Page or a Story. A page is simply a single page of content. An example of a page would be if you were to create an "About" page for your web site that simply describes the nature of your business. A Story is a collection of pages that, together, combine and create a common piece of content. An example of a Story would be a web site tutorial. We can now create some content on our web site by clicking on the Page link. We can provide a Title and Body for our page, as follows:

We can then click on the Save button, at the bottom of the page, to create our first page.

Now that we have created our first Drupal page, we are ready to move onto Flash.