Setting Up Account Emails

When a new user registers on your site, Drupal will send them a Welcome e-mail. When a user requests a password reset, an e-mail is sent with the details. E-mails are sent for various account-related activities. You can configure these e-mails on the Account Settings page as shown in Figure 7-8. Welcome (new user created by ad min i stiator) Customize welcome e-mail messages sent to new members upon registering, when administrative approval is required. Available variables are slte najne . site...

Step Create the module File

This is a step that is easier said than done. To begin, you first decide where your module will start. Drupal modules do not start from line 1, but rather, from any one of Drupal's hooks. In the second exercise, hook_node_view was the starting point for the module, but only when Drupal is displaying a node. If the module also implemented hook_comment_view, it would contain two starting points one when a node is viewed and the other when a comment is viewed. Drupal is built using the PHP...

XML Sitemap

Search engines such as Google, Yahoo , and Bing crawl sites all the time, looking for snippets of text that will tell them what a site is about. An engine typically finds a hyperlink that links to a piece of content that in turn links to more content, thus recursively searching a site or sites. This method doesn't allow the search engine to find everything, and it doesn't tell the engine what is and what is not important on your site. For example, if your contact page contains numerous links to...

Your First Drupa Website

WHAT YOU WILL LEARN IN THIS CHAPTER > How to create an Article (news story or blog entry) > How to create an About Us page > Adding the RSS (Syndication) block to your sidebar > Enabling and configuring your Contact Form > Modifying site permissions to create a members-only website > How to create new user accounts > Downloading and installing a new theme Quickly get up to speed on your new Drupal website by following along with this chapter. In this overview, you will create...

QQ Creating a Patch File

In this exercise, you create a patch file against the beginning_drupal module. NOTE In order to complete this exercise, you will need to have the diff and patch applications installed. Mac OS X and Linux include these utilities, but Windows does not. Windows users can download and install diffutils from Alternatively the Cygwin shell can be used http cygwin.org. Follow these steps to create the patch 1. Create a copy of beginning_drupal.module, and name the new file beginning_drupal.module....

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...

Baseurl

This setting directs Drupal to always return the same base URL, regardless of how the user accessed the site. For example, if your site is hosted at http mysite.local drupal7 and is also hosted at http mynewsite.local, you can force Drupal to always return http mynewsite.local. Set this variable like the following baseurl http mynewsite.local This can be a great setting if you are transitioning a website to a new URL but be aware that Drupal does not send a 301 redirect with this setting. A 301...

Advanced Views

This chapter covers Views' immense and complex Graphical User Interface GUI . But Views also contains an even more powerful Application Programming Interface API that allows module developers to extend and enhance views. Because it is an advanced developer topic, this book does not cover the API. You can learn more about the API on the Views project page at http drupal.org project views. There is one topic, however, that even non-developers use from time to time embedding a view. Embedding a...

Advanced Search Settings

During the first Try It Out exercise, you set a permission that allowed authenticated users to use the Advanced Search features available at http localhost search and shown in Figure 9-5. The Advanced Search options allow a user to limit their search to a specific content type, use negative queries, or search for whole phrases. Keep in mind that conducting a search using the Advanced Search settings takes longer and utilizes more system resources, which is why you did not grant the permission...

Style Settings

After completing the preceding exercise, you most likely discovered an ugly block that looked like your site's frontpage crammed into the left sidebar, which was probably not what you were expecting. The left side of Figure 11-21 shows what your default block would look like if left as is. This section introduces Style Settings, which will transform your block into the much cleaner and summarized block shown on the right side of Figure 11-21. You will also learn how to create lists, tables,...

Bit Of Terminology

The term internationalization is often used as a very broad and ambiguous term referring to numerous actions, all of which relate to modifying Drupal's core language English and its settings. Internationalization generally relates to two activities localizing and translating. Here are a few terms to help you decipher the lingo of internationalization Localizing Refers to the modification of the user interface to the local standards. This may include translating the text used for menus, buttons,...

Arguments

Arguments are a powerful and often underutilized part of Views. An argument is a variable that alters the results returned by a view in other words, it is a dynamically configured filter. For example, Figure 11-32 shows the argument jredding being used with the gallery URL the view . This argument will filter the results so that only photos from jredding are shown. Photos byjredding 3 Beginning DrupaE In this section, you'll modify your gallery so that the photographer's name appears below...

Robotically Promote Content to the Frontpage

Using the Rules module, you will create a rule that automatically promotes a node to the frontpage when a member of the Editors role posts a comment on the node. The following prerequisite steps were performed in the exercises earlier in this chapter Create a new role named Editors. Create a user account named Editor and add this account to the Editors role. Before proceeding download, install, and enable the Rules module, which also includes the Rules administration UI module. You can download...

Forcing Sessions to Expire

Although the default behavior of Drupal is to let a session last quite a long time, it can be desirable to override this behavior and force a session to expire earlier. You may choose to do this because you are running a secure application that must verify your user's identities or because of server limitations when dealing with millions of users and their associated sessions. Each session is stored in the Drupal's database session table, and a million sessions on a slow database server can...

QQ Adding Taxonomy to Your Content

In this exercise you will add a Food Type category to your Article content type allowing you to categorize the article as about Asian or Middle Eastern food. This exercise will walk you through three basic steps 1 adding a vocabulary, 2 adding terms to the vocabulary, 3 adding a taxonomy field to the Article content type. Step 1 - Adding a Food Type Vocabulary 1. Navigate to Taxonomy by clicking Structure in the top administration bar then Taxonomy. 2. Click Add Vocabulary at the top of the...

Making Your View Accessible via a

A great trick when using Views is to place your custom view alongside existing tab or menu structures. Take a look at Figure 11-47 and notice that the selection Comment Review selection is available alongside Drupal's default administration pages. Also consider Figure 11-48, which shows a custom tab on the user's profile page that links them to a custom view with a listing of all of their comments. ft Dashboard Content Structure Appearance People Modules Configuration Reports Help Heflo...

Approving Accounts in Moderation

When administrator approval is required for user accounts, Drupal sets the newly created user account to blocked status. You will have to manually unblock the account. Follow the next exercise to learn how to do this. In this exercise, you unblock newly created user accounts. Please complete the previous exercise before continuing, if you have not already done so. 1. Log out of your website. Create a new user account by clicking Create New Account under the User Login block as shown in User...

Widgets Form Element

A widget is used for the display of the field during node creation or editing and is specific to the field type. For example, a list field type contains two widgets checkboxes radio buttons or a select list. The results of each are the same, that is the user can choose one or one or more options, but the presentation of the field differs. Returning to your Gossip content type consider if you added a field for the Gossip's truthiness allowing users to select one or more options that describe how...

All Views Permissions

These permissions control access to all views. You can configure the following all-views permissions at Configuration C gt Permissions Administer Views This permission grants access to create, edit, and delete every view on the system. Needless to say, this is a very sensitive permission and should only be granted to trusted users. Access All Views The name of this permission is slightly misleading. It allows users to bypass per-view permissions in order to see every view unrestricted. This...

Indexing Your Content

Indexing your content could also be called making your site's search engine work. If you perform a search after completing the previous exercise, you won't get any results this is because your site has not been indexed yet. Indexing occurs automatically when your site runs cron discussed in Chapter 3, Your First Drupal Website . You can see the status of your site's index, as shown in Figure 9-2, by navigating to Configuration C gt Search Settings. You can either wait for your site to run cron,...

Preflight Checklist

WHAT YOU WILL LEARN IN THIS CHAPTER gt Using a basic checklist for site maintenance, users, Search Engine Optimization SEO , performance, and disaster recovery to cover all your bases before going live gt Setting up and optimizing SEO for your site gt The importance of clean URLs and URL aliases gt An introduction to Google Analytics, and installing the module to monitor your site's activities gt Configuring your dashboard You are nearing the end of your Drupal journey. In the previous...

The Need for Speed

If you find that your site needs better performance than Drupal's core provides, look into using one of the following modules. Boost with large numbers of anonymous users can see a very significant performance boost with this module. The module is simple to install and easy to configure. Memcache with large numbers of logged-in authenticated users can increase performance by caching the requests made to the database through the use of a third-party caching mechanism called memcached. The...

Custom Administration Pages With Views

When your site begins to grow and you find yourself with thousands, tens of thousands or, lucky you, hundreds of thousands of users, you might find that the built-in user management interface does not provide you with enough options. For example, you may want a page that displays the users that have logged in within the past X days, or a listing of all users with an e-mail address from a certain domain. The marketing department may want an up-to-date report on the number of users within a...

Content Ranking

A better title for this section might be How to Define What's Relevant to Your Users. Content ranking allows you to modify the order in which results are returned during a search process, and help direct Drupal to what is relevant to your users. Opposite of most ordering in Drupal, a higher number means higher relevancy. The example shown in Figure 9-7 would cause content promoted to the frontpage to be returned higher in the search results than other content with a high number of user...

Analyzing Your Site With Google

Few web statistics tracking systems are as user-friendly and versatile as Google Analytics. It enables you to view a wide range of data about traffic to your site, including the top content of the day or month, where your visitors are from, which search engines and sites send the most traffic, and much Analyzing Your Site with Google 411 more. Google Analytics also support something called goals, which allow you to set a target such as a 50-percent increase of traffic to your shopping cart and...

Exposed Filters

An exposed filter is a Views filter that can be modified by the user in real time without the user modifying the underlying view. Consider Figure 11-40, which shows an example of a custom Comment Moderation page. The filters at the top of the page are modifiable by any user with permission to see the view. Similis Roto Usitas Nibh Velit Inure Exposed filters are a great way to create custom administration pages such as the Comment page shown in Figure 11-40. In the next few exercises, you'll...

Translating Your Content

The second half of creating a multilingual site is to translate your site's content the Articles and Pages you have added to the site. If you will be a running a monolingual site, there is no reason to add content translation, because you can simply submit all of your information in that language. You translate your site's content using Drupal's core Content Translation module. This module provides a method to translate your site's content and a method to link a piece of content to multiple...

Display Multiple Terms on a Single Page

You may be wondering how you can create pages or feeds that display content that is categorized within a set of terms. For example, Articles categorized as Middle Eastern OR Japanese. This is accomplished by using the Views module and also occurs within the Argument options you saw in the previous exercise. Return to Step 6 of the previous exercise and the options of the Taxonomy Term ID argument. view taxonomy_term C gt Arguments, click on the Term ID argument . Setting the Argument type...

Example Multiple Independent Websites

In the following example you'll create two websites using a single installation of Drupal. The keys to this configuration are A unique site's folder named after the URL A unique database or database table prefix When hosting multiple websites Drupal separates them by using the respective Sites folder. Each website's folder is named after the URL of the website as described in Chapter 2. Follow the activity to learn more. With an existing site already operating at http localhost, you're going to...

Recent Log Entries

Every site will generate database and system messages that range from simple notifications such as Session opened for Joe Smith meaning that he logged in to critical system errors that require immediate attention. Drupal stores these messages and retains them accordingly to your site's setting at Configuration C gt Development C gt Logging and Errors. At first glance, the Recent Log Entries page may be intimidating and filled with too much noise to be useful. However, you can use the Filter Log...

Zen Base Theme

In the last exercise you used a sub-theme to make a minor change to a new theme that you built from the ground up. Sub-themes built from a solid foundation can dramatically speed up your theme development by predefining the key aspect of a theme leaving you time to focus on the creative and design parts of a theme. In short a solid foundation can leave you more time to bring your theme to nice polished shine. Enter Zen. Zen is a standards-compliant base theme built and supported by a worldwide...

Creating A Photo Gallery

Adding images in Drupal gets easier with every new Drupal release, and Drupal 7 makes it positively child's play. Image styles, introduced in Chapter 6, Content, automatically create thumbnail, preview, and large versions of uploaded images. Views can then pull these images and display them in a 3x3 grid, 4x4 grid, vertically, horizontally, or in nearly any manner you can dream of. Follow along in the next two exercises to create a photo gallery like the one shown in Figure 11-27. In the first...

Custom Theming

This is the part of the chapter that gets down to the meat of things. You are here to learn how to customize your site and make it uniquely you or your client on the web. Over the next several pages you are going to do exactly that. You'll walk through five exercises, which will transform the plain core Stark theme from that shown in Figure 13-6 to the Drupal and the Chocolate Factory theme shown in Figure 13-7. The exercises are designed to introduce you to theming in a high level overview...

Submission Form Settings

A node must have a Title field although you may change the label that appears on the node creation form. For example, if you have a node type for file uploads you may change this label to File Name. The Body field is optional. If this node type will not have a body, simply leave this field blank. This setting will affect future nodes as well as any node edits. This means that if you create a node type Gossip Machine name gossip Edit The human-readable name of this content type. This text will...

Block Visibility

By default blocks appear for all users on all pages. This is not always desirable. For example you wouldn't want the administrative menu appearing for anonymous users. Also you may want the recent comments block to only appear on the blog page or advertisements displayed for anonymous users but not for logged in users, giving people incentive to sign up. Drupal provides four methods for you to control the visibility of your blocks as shown in Figure 5-8, Page specific, Role specific, Content...

Comment Approval Queue AKA Comment Moderation

At the top of the Comment Administration Page, shown in Figure 6-38, is a tab entitled Unapproved comments. Comments appear on this tab via two methods Comments left by users who have the Post Comments permission and do not have the Post Comments Without Approval permission. In this exercise, you will implement moderated comments on the Gossip content type for all anonymous users, but authenticated users will be able to post without moderation. Follow these steps 1. Ensure the Comment module is...

System Site Information

Site information is located under System and consists of many of the items that you configured during installation. The most commonly adjusted item in this area is the default frontpage setting. Top to bottom, the settings are as follows Site name The site's name appears in the title bar of the web browser to the right of the vertical line I shown in figure 4-4 and is often displayed on the top of every web page shown in figure 4-5 . Keep in mind that this name is used when users bookmark your...

Creating an Editorial Review Workflow

Follow these steps to create an editorial review workflow with Draft, Editor Review, and Approved Published states. Please note that at the time of writing the workflow module was not updated for Drupal 7. This chapter describes the process for Drupal 6, which should be similar to that for Drupal 7. 1. Ensure that the Trigger module is enabled. 2. Download, install, and enable the Workflow module 3. Create two new roles Writers and Editors. 4. Create two user accounts Writer and Editor. 5. Add...

Adding a Link to the Contact Form in the Menu

In this exercise, you make it easier for your site visitors to contact you by placing a link in your site's Main menu. 1. Log into your website as an Administrator. Click Structure in the Administration menu at the top of the screen, and then click Menus. 2. Click List Links to the right of the Navigation menu. 3. Click Edit to the right of the Contact menu link. 4. Modify the form with the following information as shown in Figure 3-20 Description Contact us to advertise on our site or to...

Add a New Link to the Main Menu

This exercise walks you through adding new links to the main menu. You will add a link to the first article node you added in Chapter 3. 1. Log in as an administrator and navigate to Administer O Structure O Menus. 2. To the right of Main menu click Add Link. 3. On the Create link page type in the following information as shown in Figure 5-18 Menu link title My first article Description My first Drupal article Home Administer Structure Menu i Main menu MENU SETTINGS Menu link title My first...

Modifying the Default Taxonomy Depth

In this exercise you explore the Views module default taxonomy term page and modify the depth to display all child terms. 1. Download and install the Views module from http drupal.org project views. 2. Once installed, navigate to Administer C gt Site building C gt Views Drupal 6 . Drupal 7 should place it at Administer C gt Structure C gt Views or provide an option in the top Administration bar. 3. The main page of Views displays a listing of every available view. A view may be a URL path, a...

Install Drupal With Drush

At this point in your Drupal journey you may have come to realize the Drupal is much more than a CMS. In fact many people are starting to consider Drupal an operating system because it operates your website i.e., system . Just like an operating system, Drupal has to be managed, upgraded, and updated to remain a secure, bug free system. To help with this the Drupal Shell Drush was created. Drush can automatically update your modules and core to the latest version, install and enable modules,...

One Drupal Many Websites

As mentioned before, a single Drupal installation can be used to power multiple websites. This process is known as multi-site. Using Drupal to power multiple websites gives you several advantages, including A single point of upgrade when security updates or bug fixes are released for Drupal or any of the modules or themes you are using. The ability to roll out a module or theme to multiple sites but only installing it once. Also the ability to upgrade the module or theme for all sites by...

Block Visibility Using PHP

The visibility settings described above provide quite a bit of flexibility but you may find that you want to set visibility based on a unique custom criteria. With the PHP filter module enabled, an option to use PHP to control visibility settings will appear under the Page specific visibility settings as shown in Figure 5-15. With a bit of PHP you can set visibility based on almost anything. Here are two examples to help get you started. This example will display the block when the time on the...

Simple Test Assertions

At this point your test doesn't test anything so you'll pass with flying colors. SimpleTest uses assertions to test for certain conditions. A single .test file can contain hundreds of assertions with each one testing different items. Each assertion is either true or false to indicate a pass or failure. One of those assertions is assertEqual, which is used as follows this- gt assertEqual variable, what it should be , Message this- gt assertEqual x, 1, t 'X was properly set to 1' If x is indeed 1...

IP Blocking

Unfortunately, websites are under continuous attacks from spambots and would-be hackers. Drupal has built-in security on its forms and can block IPs through the administrative interface but these mechanisms require Drupal to start up, which can be a drain on precious system resources. Setting conf 'blocked_ips' within settings.php blocks the IP before Drupal starts saving precious system resources. The following blocks users originating from the IP 192.168.0.1 or 192.168.0.2 from accessing your...

Installing Drupal

WHAT YOU WILL LEARN IN THIS CHAPTER gt Installing a Drupal website gt Installing Drupal using the Acquia Distribution gt Exploring the files, folders and structure of Drupal gt Reviewing the sites folder gt Exploring inheritance and overrides gt Overriding Drupal's default theme with one of your own Now that you have decided to use Drupal the next step is to download and install it. In fact you might have already installed one or more Drupal websites. Even if you have already installed Drupal,...

Automatically Demote Content from the Frontpage

In this exercise, you will expand upon the previous example and schedule automatically promoted content to be removed from the frontpage after four hours. You will need to have completed the previous two exercises. You need to first create a rule set that demotes a node content from the frontpage. Follow these steps Navigate to Administer C gt Rules. Click Rule Sets and then Add a New Rule Set. Enter the following information, as shown in Figure 10-26, then click Save Label Demote content from...

Chapter

Why is it useful to understand the basics of SEO Knowing what terms to use for subjects, tags, and other important text, and knowing where to place those terms allow search engines to properly index your site's contents. In addition to making content available to search engines, SEO can help boost your site's rankings so that your content can get higher visibility. 2. What does the Pathauto module do The Pathauto module automatically creates self-describing URL aliases for you based on...

User Profiles vs User Fields

You may be asking yourself what the difference is between the Profile module and user fields. This is the confusing part on the surface the two methods are nearly identical. They both allow you to capture additional information from the user. If your goal is to capture only public information that is, information added by the user and available to all site visitors the differences won't seem significant if there are any. However, if you are capturing private and hidden information, the...

Page Cache for Anonymous Users

The Page Cache for Anonymous Users setting can dramatically increase the speed of your site for anonymous users, while decreasing the load on your server. This is a win-win setting and should always be enabled on a production site. When this is set to Normal, Drupal will send anonymous users a page from the cache instead of building one from scratch, dramatically increasing performance. However, when you're developing a site, you may not immediately see the changes you make to settings, themes,...

The Power of Image Field

As first glance the image field seems rather basic allowing a user to simply upload an image. Image field, however, is quite powerful with a few built-in features that can help your site looking good by automatically cropping, resizing, rotating, or even converting them to black and white. Each field is configured individually so begin by navigating to the Gossip Content type and clicking the edit operation for your image field, as shown in Figure 6-13. GOSSip N. EDIT MANAGE FIELD5 DISPLAY...

Content Authoring Text Formats

Text formats are the front line defense that not only keeps your site free of malicious code but also keeps it looking good. Text formats can remove, add, modify, or interpret the text entered into an Article or Page body, comment Figure 4-16 , or into any text area on your Drupal site. In other words it can modify the appearance of your content. For example, text formats can remove curse words from comments, enable WIKI syntax in blog entries, or add BBCode to your forum. You can set up...

Displaying The Results On The Users Profile

The module is nearly complete comments are being tested for restricted words, and the attempts are logged but one critical element is missing. You can't see the counter. In this next exercise you'll use hook_user_view to display a count of each user's attempts on his or her profile page. You could call this shaming them into cleaning up their commentary. A user's profile is accessible by clicking the my account link in the navigational menu. In the following exercise you'll implement...

Drupal Query Functions

As with the Schema API, whenever you are adding, retrieving, or manipulating data in your database you should always use Drupal's specific query functions. Amongst other reasons the use of the queries helps with scalability. For example when your site becomes very popular you could employ multiple database servers to handle the increased load. You can only do this if you use Drupal's functions. Compare the following two sets of code that enter the same data into the same table. One using MySQL...

Scheduler And Rule Sets

The Rule Scheduler module straightforwardly schedules rules. However, it doesn't schedule the rules that you have been working with in this chapter. Those rules are known as triggered rules, meaning that they have some sort of trigger event. The Rule Scheduler module schedules rule sets, which have no trigger event. A rule set is a collection of rules that will be triggered by something other than a system event. This trigger could be custom PHP code or a schedule. To demonstrate how a rule set...

Controlling Access to User Profiles

In order to view the public fields of your member's profiles, the viewing user must have the View User Profiles permission. By default this is only granted to Administrators your visitors are unable to view the profiles although they can fill out their own personal profiles. Follow the next exercise to grant and to view the page created for all members interested in a particular sport. UQ Enabling Access to Your Users' Profiles In this exercise, you grant anonymous users the ability to view...

Bandwidth Optimization

A default installation of Drupal sends approximately nine separate Cascading Style Sheets CSS files to the client. When combined with JavaScript files, this number can grow to over 14. Every visitor to your site has to retrieve each one of these files, causing their browser to work harder and causing the overall experience of your website to be slower. Microsoft's Internet explorer web browser also imposes a 31 Style Sheet limit, often resulting in a broken website a site with numerous modules...

Tracking User Activity

What is the most active thread on your website Is there a particular blog post generating a lot of comments What is the most recent activity for the user Sally or John If you have questions such as these, the Tracker module is what you want. The Tracker module provides a method to stay on top of your site's activity and provides users a way to stay on top of their personal activity. Simply enable the Tracker module, and you're off and running. A Track tab will appear on each user's account page...

Media File System

This section defines where your images, videos, documents and other uploads will be stored. Although Drupal defines a few defaults to get your site up and running you should take a few minutes to understand how and where Drupal stores your files. The first two settings on this page are the locations of your public files and your private files as shown in Figure 4-11. Public files are considered files that are accessible to the entirety of the Internet for unlimited, unrestricted download....

CJK Handling

Simple CJK handling helps Drupal index Chinese, Japanese, and Korean content by splitting a string of characters into distinguishable and searchable individual characters. This feature has no impact on performance and is best left checked unless you have installed a module external preprocessor that will assist Drupal in indexing CJK content. WARNING Drupal's built-in CJK handler, also known as a tokenizer, is a very basic handler, and although it works great for occasional C J K language...

Introduction

OVER THE PAST FEW YEARS, the Web has undergone dramatic changes. What originally started as a handful of static web pages with a few e-commerce sites in the mix has now turned into a frenzy of collaboration and information sharing. New websites are expected to meet a certain level of interactivity and information-sharing. RSS feeds, blogs, and podcasts are just a few of the current standards. Photo uploads with auto-resizing and cropping, video and audio embedding, and even web APIs are quickly...

Temporary Directory

The temporary directory is necessary for Drupal to function and is periodically cleaned out by the modules that use it. Proper cleaning of the temp directory requires a properly running Cron so be sure that it is functioning correctly Chapter 3 . The temporary directory should not be placed in a folder that is accessible over the Web as several modules use this space to temporarily store uploaded files. Crafty visitors may search for any sensitive or forgotten files in the temporary folder as...