The searchtotal table
Take a look at what the search_total table contains after indexing example nodes 2 and 3 raysql gt select from search_total order by count desc word 1 count j____________i___________ Figure 20 Global normalized totals for the words in the index. After each time that indexing occurs, all of the words that have been marked by search_dirty will be updated in the search_total table. The count value is a normalization according to Zipf's law that says a word's value to the search index is inversely...
The allowed domain and crossdomainxml
The allowed domain is the value that gets populated within the crossdomain.xml file of our Drupal site. The crossdomain.xml file is a file used by Flash to determine which sites it can communicate with and which sites it cannot. The Services module automatically generates this file using the Drupal menu system. We can see the contents of this simulated file by visiting our domain followed by crossdomain.xml, such as Although we do not have a crossdomain.xml file within our Drupal root on our...
Virtual Reality
Humans have literally dreamed about virtual reality for probably their entire existence. Every night, each of us enters a simulated reality that competes with the world we experience during our waking state. The Taoist philosopher Zhuangzi, in a well-known musing, dreamed once that he was a butterfly. Upon waking, he wondered if it were he that dreamed of being a butterfly or if he were the butterfly dreaming of being Zhuangzi. Though it seems a pipe dream to build a simulated reality that can...
Converting a Drupal x Theme to a Drupal x Theme
Drupal themes have changed radically from version 5 to version 6 however, there is no reason to change the design of page that is displayed to Web site visitors when you upgrade the theme from one version of Drupal to another. Keeping this point in mind, you should find it a relatively quick task to upgrade a theme with only a few minor changes to your current theme files. Work through the following checklist to create a Drupal 6 theme 1. Create an information file for your theme. This file...
Cropping and Resizing
After your video material is loaded into Avidemux and is playing back correctly, and you can hear the sound, you can use the editing features in the program before you perform the output encoding. Often, if you're preparing video for the Internet, you have to reduce the resolution, change the aspect ratio, or cut it in length. Skipping this step may mean your video is edited or resized automatically by the video server, which can lead to unacceptable results. Suppose you have some digital...
Populate the Primary Links
In this step, we will add some useful links into the Primary links menu. As you populate the Primary links, think about the work your site members will be performing. You want your primary links to act as doorways to their most commonly-performed tasks. The process for adding menu items into the Primary links is just the same as moving them into other menus. As shown in the following screenshot, when editing an existing menu item, select Primary links as the Parent item. The maximum depth far...
The Basic Page and Article Content Types
When you install Drupal 7 you automatically receive two content types that have been defined by the team who maintains Drupal core the Basic page and Article. If you author a piece of content using the Basic page content type you will see that it provides two basic fields a title and a body. An author using the Basic page content type simply enters a title a required field as indicated by the red asterisk and the text of their content in the body field. The body field is flexible and can...
Items Per Page
If you decide to use a pager for your view, you can set the number of items that will appear on each page by clicking on the small gear icon to the right of the Use pager option. Clicking on the gear reveals a form where you can set the number of items that will be displayed per page, the offset think of the offset as the starting item for your view for example, if you want to skip the first 10 items and start at number 11, you would enter 10 in the offset field , the pager ID in nearly every...
Connecting to Multiple Databases Within Drupal
While the database abstraction layer makes remembering function names easier, it also adds built-in security to queries. Sometimes we need to connect to third-party or legacy databases, and it would be great to use Drupal's database API for this need as well and get the security benefits. The good news is, we can In the settings.php file, db_url can be either a string as it usually is or an array composed of multiple database connection strings. Here's the default syntax, specifying a single...
Content profile
Location This module builds user profiles as content also known as nodes , which opens the opportunity to use all the powerful modules for content for user profiles too, for example, the Content Construction Kit CCK . It's intended to be simple and useful, but extensible by further modules. The setting for Content Profile is an extra pane in the content type settings. If checked, that content type is used as the user profile. If unchecked, as shown next, that particular content type will not be...
Embedded Media Field
Finally, we come to the alternative of hosting video from our own servers. Although using a module such as Media Mover combined with services such as Amazon S3 nukes serving video a slightly easier task than it might have otherwise been, for most sites the bandwidth required for serving video is generally not a viable option. Additionally, sites may wish to take advantage of the viral opportunities of hosting video through a widely recognized provider such as YouTube or Blip.TV. There are...
Configure the Base Content Profile Settings
To configure the base Content Profile settings, click on the Administer Site building Content types link, or navigate to admin content types. Click the Edit link for the Profile content type. Then, click the Content Profile tab. The base settings allow us to configure how the node profile will be displayed on the user profile page. As shown in the preceding screenshot, in the User page display style section we have four options Don't display this content profile on the user account page only...
Installing a Drupal theme
After you have decided the best theme to go along with your online store, you should follow these steps to install it. This is a rather straightforward procedure, very similar to the one performed in Chapter 2, Installation of Drupal and Ubercart, during module installations 1. We will go through installing the second most popular Drupal theme according to Drupal.org statistics. Go to http drupal. org proj ect acquia_marina and click on the download link next to the 6.X-1.9 version. By jwolf on...
ReArranging Blocks
It is likely that, at some point in time, you're going to want to re-order how blocks appear on a page. In the previous example, we may want to have the Who's new block appear above the Who's online block. To re-order the blocks, navigate to the Blocks page by clicking on the Structure link at the top of the page. On the Structure page, click on the Blocks link. Once on the Blocks page, simply click and hold the plus sign next to the block that you want to move, and drag that block to the...
Use Pager
For lists that will contain dozens or hundreds of items, you can limit the number that appear on a page usually to 10 or so and use a pager at the bottom of the page instead. A pager looks like this lt lt previous 1,2,3,4,5,6,7 next gt gt . Visitors use the pager to navigate through all of the items. Views automatically creates and displays the appropriate pager based on the number of items that are in the complete list. By default, the Views module renders lists using a pager with 10 items per...
Local Video Files
When serving local video files, we have to consider first how a video will be placed onto the server and if we require any manipulation of the video. We may wish to use an upload field from a web form, or we may wish to use FTP to upload large files, or we may wish to be able to email a video to the server as from a cell phone. All of these options are available, so we will examine each in turn. The first heavy hitter is the FileField module. This light-weight module goes a long way. At its...
Triggering Hydrogen Drums with Seq
Because the Hydrogen drum machine accepts both MIDI input and JACK transport control, you have two options for synchronizing it with sequences created in seq24. You can either make a drum pattern in seq24 and trigger Hydrogen on MIDI channel 10 or create the pattern in Hydrogen's sequencer and use seq24's play button to get the transport rolling. Hydrogen accepts MIDI input on any channel, but you can get specific by choosing File gt Preferences gt MIDI System gt Channel. If you want to, you...
Permissions
We'll cover the permissions for a core Drupal install here, and for the add-on modules in the appendix. The block module is for creating the blocks that can be placed in various regions on the site. The permissions settings will depend on who will be administering them these particular permissions don't affect their viewing. With this site, the site owners will not be performing site administration themselves, so we will leave those permissions to User 1 the super admin and not assign them to...
Configure the Audio Module
Now that we have installed the Audio module and its helper modules, we need to configure the audio module to support our needs. Click the Administer Site Configuration Audio link, or navigate to As pictured in the following screenshot, you will see three tabs across the top of the page Audio, Metadata tags, and Players. Home gt Administer gt Site configuration The current PHP configuration limits file uploads to 8 MB. Tfiere are two PHP ini settings, upload_max_filesize and post_max_size, that...
Create a Gender field
The Gender field is also built in a similar way to the other two fields, but with a different component. For this field, we will be using the Select component. Therefore, we will need to present options to the user to select from. The values to be entered for this field are shown in the following screenshot This is used as a descriptive label when displaying this form element. Default value The default value of the field. For multiple selects use commas to separate multiple defaults. 0 Token...
WinMerge
While these programs do a nice job in showing file differences visually, side by side, non of them as i can tell allows to actually save the difference in unified format most allow to save a standard diff, though - update TortoiseCVS lets you save patches. It does unified format by default. See its Make Patch option. Note that this 'Make Patch' option can make recursive patches when applied to directories. You cannot specify the -u in the External diff preferences eg diff -u as this will...
Modifying Nodes of Our Type with hookload
The last node-related hook you need for your basic joke module is the ability to add your custom node attributes into the node object as it's constructed. We need to inject the punchline into the node loading process so it's available to other modules and the theme layer. For that you use hook_load . This hook is called just after the core node object has been built, and is only called for the current node type being loaded. If the node type is joke, then joke_load is called. Implementation of...
Shape Tools
Inkscape has a good selection of preformatted shape tools to satisfy the five-year old potato printer in you. These shape tools provide a useful way to start playing around with the possibilities of this application, and it's possible to achieve many different effects. You can manipulate the shapes via their nodes small square ones for resizing, and round ones for reshaping. Drawn shapes are objects by default, rather than paths, but as usual you can convert them to paths with the Path gt...
Getting Started with Panel Pages
The starting place, as always, is downloading, installing, and enabling the Panels modules along with the Chaos Tool Suite. There are three modules in Panels their settings are shown in Table 20.1. Download from Enable in section Permissions Panels Mini-Module Panels Module Panels Node Module Administration Administer, Site Building, Panels admin build panels Administer, use, and view use panels dashboard Administer, create, and edit The Chaos Tool Suite module also needs to be downloaded, as...
Configuring the Genesis Theme
If you haven't done so already, follow the instructions in Chapter 6 and install the Genesis theme www.drupal.org project genesis . You'll notice that the installation process creates two versions of it Genesis base and Genesis subtheme. A majority of Drupal starter themes use subthemes as the mechanism for creating a new theme based on the foundation provided by the base theme. This allows you to create one or several new themes using the same underlying foundation without having to start from...
Facebook features apps to keep visitors hooked with more things to do
facefaook Home Profile Friends Inbox 52 Steven Ch an finished enteric gram negative bacteria, but got tired of the anaerobes, still need to catch up on pathoiogv and ph arm . dear 864 members - S6 donated - Viewtause acebook features apps to keep visitors ooked with more things to do. Opensocial aims to do the same as Facebook apps. OpenSocial defines a common API for social applications across multiple websites. With standard JavaScript and HTML, developers can create apps that access a social...
Finding the List of Available Blocks
To find the list of blocks that are available for you to use on your new web site, click on the Structure link at the top of the page. This takes you to the Structure page. On the Structure page, click on the Blocks link to reveal the Blocks page, which lists all the defined blocks on your system, including those that are already assigned to regions and those that are not assigned to a region. See Figure 7-2. 4 P we red by Drupal 4t Who's online Management tf- User iogin Navigation Search form'...
PHP XTemplate
PHP XTemplate was once the default theme engine in Drupal but has fallen by the wayside as development of the application slowed. For many users, XTemplate was a popular system. It separates the HTML from the PHP and makes it easy for designers to work with themes. Also, as it is written in PHP and can handle either PHP4 or PHP5, it tends to perform well with Drupal. Unfortunately, at this stage, it seems unlikely to be making a comeback in the near future, and those of you who previously...
Committing to the Repository and Tagging the Initial Prototype
Well, you have certainly done a good bit of work. Enough already. You are definitely at a point where you would want to commit your work to the repository and call it a day. You will be doing this a lot, every time you finish an atomic piece of work in the future roughly corresponding to each section or subsection in this chapter . So let's just review these three quick easy steps 1. Dump the database You can do this via phpMyAdmin if the database isn't too big and it won't be for quite a...
Edit the Settings of the Profile Content Type
As mentioned above, when the Content Profile module is enabled, it creates a new content type named Profile. To use this new node type effectively, we need to change the default settings. To do this, click on the Administer Site building Content types link, or navigate to admin content types. Click the Edit link for the Profile content type. The Automatic Nodetitles module enabled earlier in this chapter adds a new fieldset labelled Automatic title generation at the top of the administrative...
User settings
From here, we can configure the registration requirements of our users, email templates used for new accounts and so on, and users' picture settings. We can determine what security precautions should be taken when a new account is registered. New accounts Can only be created by an administrator Can be created by a visitor, but require administrator approval Can be created by a visitor without administrator approval and in addition to the previous two, require user email verification User...
The searchnodelinks table
The tokens in Figure 3 didn't contain any links. Here's some text that links back to node 2 the node that talks about ponies and badgers lt a of badgers and ponies lt a gt This is in node 3, and the link references node 2. Now look at the contents of the search_node_links table after node 3 has been indexed mysql gt select from search_node_links Figure 18 search_node_links has caption text that will be added to a node's text at indexing time. The utility of this text only makes sense if we also...
Approving Requests for User Accounts
Drupal lets you, the site administrator, determine how user accounts are created on your website. You can Allow site visitors to create their own accounts without approval by a site administrator. Allow site visitors to request an account, but require that a site administrator approve it before allowing the visitor to use the account. Restrict account creation to only the site administrator. The approach you use is completely dependent on whether you allow visitors to have their own accounts....
horizscrollhtml
The horizscroll.html file contains the HTML code that allows the JavaScript code from horizscroll.js to attach its behavior. It also contains all variables for the data source. lt xml version 1.0 gt lt DOCTYPE html PUBLIC - W3C DTD XHTML 1.0 Strict EN lt html xml lang Men lang en gt lt head gt lt meta http-equiv Content-Type content text html charset utf-8 gt lt link rel stylesheet href horizscroll.css type text css gt lt script src jquery.js lt script src drupal.js lt script src horizscroll.js...
Organic Groups Module
One of the hallmarks of vibrant online communities is the presence of a common interest or theme that unites those who are involved. Whether this common interest is relatively broad or narrow, there are likely to be smaller but related topics that are of interest only to a subset of the community. For instance, on a music school site, the brass players might want to organize their own rehearsals and brass ensemble concerts. The ability for these people to band together and form a group is the...
The DTP Revolution
Although personal computers quickly replaced the humble typewriter, the art of typesetting and laying out high-quality printed documents took a little longer to go digital. True desktop publishing software is usually known by its acronym, DTP. This kind of program differs from word processors and home or small-office publishing packages in the precise level of control over the document that it enables. Designed for high-speed use by an experienced operator, a true DTP program doesn't try to...
Enabling and Cloning the Backlinks View
To get started, click the Administer Site building Views link, or navigate to admin build views. As shown in the following screenshot, enable the default backlinks view. Default Node view backlinks default Displays a list of nodes that link to the node, using the search backlinks table. Once we have enabled the backlinks view, we want to clone it. So, we click the Clone link. Change the View name to conversations, and change the View description to Cloned from default backlinks view displays a...
Test Driven Development
You have been introduced to testing after writing your module because this book is designed for users new to Drupal and or new to development. Many developers have shifted to writing their tests before writing their code to ensure that the code is written correctly and to reduce bugs during development. This is known as test-driven development TDD . Before you write your first test take some time to explore Drupal's testing environment. Follow these steps to test your website using SimpleTest...
Changing the Body Class Based on bodyclasses
One of the most useful dynamic styling tools introduced in Drupal 6 is the implementation of body_classes. This variable is intended specifically as an aid to dynamic CSS styling. It allows for the easy creation of CSS selectors that are responsive to the layout of the page. This technique is typically used to control the styling where there may be one, two or three columns displayed, depending on the page and the content. Prior to Drupal 6, layout was used to detect the page layout, that is, I...
[PACKTl 1
Formatting the Comments Form and Output We enabled the comments functionality earlier, let's now set the look and feel. The comments in the default Zen theme are shaded a light blue, consistent with the Zen color scheme. For Tao, we want to make things a little more conservative, a little more somber, so we will change that to a light gray and also apply our font selections. Make the following changes to the selectors, below margin 0 0 10px 0 padding 10px background f1f1f1 .comment h3.title,...
Creating a New Subtheme
Install the Zen theme if you have not done so before now once that is done we're ready to create a new subtheme. Installing a new theme is covered in Chapter 2. J First, make a copy of the directory named STARTERKIT and place the copied files into the directory sites all themes. Rename the directory tao. Note that in Drupal 5.x, subthemes were kept in the same directory as T .rlsT the parent theme, but for Drupal 6.x this is no longer the case. Subthemes I should now be placed in their own...
Administrator Notifications
When orders are placed we can opt for the administrator to be emailed a summary of the order, this is particularly useful when manually processing orders, and these orders are infrequent so you may not need to visit the website on a daily basis. This setting is found in E-Commerce configuration under Store. Enable cr disable transaction notifications. If enabled, the aite administrator idovgQdiugsdinGs.zQrrt v.ill receive an email summarizing the status of fill orders. The Frequency of emails...
Personal Themes
If your Web site is already live, you may want to enable your new theme privately to test its implementation before showing it to the rest of the world. To do so, you can use the Personal Themes feature of Drupal. It allows you to enable a theme that only you can view. Once the theme is working correctly as a personal theme, you can apply the theme to the entire Web site for everyone to use by following the instructions in the previous section. If you are not the main administrator for the site...
Spotlight Flag Module
The Flag module formerly known as Views Bookmark is an incredibly flexible module that allows you to create relationships between users and content on your site. After creating a flag, an item can be marked with the flag a few different ways, including links displayed below content, as shown in Figure 9-10, or checkboxes displayed on the edit form, as shown in Figure 9-11. Morbi nor erat rion ipsum pbaretra tempus Donee orci, Proin in ante, Pellentesque sit amet pur us. Cras egestas diam sed...
Citing Dependencies in the info File
While the .info files we've been using differ only in name and description, here we will make use of a new field. description Send an email message of site news to all users. core 6.x php 5.1 dependencies trigger The sitenews.info file should look largely familiar. The last line is the only one with a new directive. This last line is used to indicate what dependencies a modules has. That is, it tells Drupal which other modules must be installed before this module can function appropriately....
Access Control
In our examples so far, we've simply set the access key of the menu item to TRUE, meaning that anyone can access our menu. Usually menu access is controlled by defining permissions inside the module using hook_perm and testing those permissions using user_access . Let's define a permission called receive greeting, if a user does not have a role that has been granted this permission, the user will receive an Access denied message if he or she tries to go to http example. Implementation of...
Where Profiles Are Stored
Your Drupal site already contains an installation profile. It's the default installation profile that ships with Drupal, and you'll find it at profiles default default.profile. We want to create a new profile called university, so we'll create a new file at profiles university university.profile. For now, we'll just add a single function to the file Return a description of the profile for the initial installation screen. An array with keys 'name' and 'description' describing this profile....
Access Control
It's time to look at an entirely different aspect of running a Drupal website. Up until now we have focused on adding and organizing the site's basic functionality. We have not yet given any thought to how this functionality is to be accessed, or by whom. As the site grows, you will most likely feel the need to delegate certain responsibilities to various people. Alternatively, you might organize a team of people to work on specific aspects of the site. Whatever is required, at some stage you...
Cron and Scheduled Tasks
In order to keep the site running smoothly, and keep it up-to-date, there are a variety of chores that need to be performed on a regular basis. For example, we saw earlier in the book that the Aggregator module needed to be run on a regular basis so that it can update all its feeds. The Drupal developers are well aware that different modules all have different tasks to perform on a regular basis, so they created cron. php to manage the process. Keeping modules up-to-speed is a case of setting...
Collaborative writing
Drupal's book module is designed for creating structured, multi-page content on our site, for things such as Since our site is a social network for owners of pet dinosaurs, a suitable use for this module would be to allow our users to create and contribute to a book on looking after a dinosaur throughout its lifetime. Of course, as our site grows, it would be better to have more books related to specific breeds, which is something we can accommodate as our social network starts to grow

















