Drupal for Education and E/Learning
上QQ阅读APP看书,第一时间看更新

Installing the Text Editor

To get started using the text editor, navigate to the FCKeditor project page at http://drupal.org/project/fckeditor.

Uploading and Enabling FCKeditor

As described in Chapter 3, download the module, extract the code, and upload it into the sites/all/modules directory.

Note

In this site, we are using FCKeditor for the text editor. The support for FCKeditor within the Drupal community is solid, which is one of the factors to consider when selecting a module. With that said, other options that can be used include the WYMeditor, TinyMCE, and BUI editor.

Unlike most modules, installing the FCKeditor has one additional step: you need to download the text editor from the FCKeditor site http://www.fckeditor.net/download. You want to get the current release, which will be listed as shown in the following screenshot:

Uploading and Enabling FCKeditor

Download the files from the FCKeditor site, and extract them. Then, as shown in the next screenshot, add the new folder to the FCKeditor module code.

Uploading and Enabling FCKeditor

As shown by Item 1 in the above screenshot, the code downloaded from http://www.fckeditor.net/download goes into sites/all/modules/fckeditor.

Once you have uploaded the code, click the Administer | Site Building | Modules link, or navigate to admin/build/modules, and enable the FCKeditor module.

Uploading and Enabling FCKeditor

Click the Save configuration button to finish enabling the module.

Configuring FCKeditor

To configure FCKeditor, follow the instructions given in Chapter 3, click the Administer link, or navigate to admin, and then click the By module tab, which brings you to admin/by-modules.

Alternately, click the Administer | Site configuration | FCKeditor link, or navigate to admin/settings/fckeditor.

Configuring FCKeditor

To configure the FCKeditor, click the FCKeditor link as shown in the preceding screenshot. This brings up the administrative screen shown in the next screenshot:

Configuring FCKeditor

Assigning Permissions

As you can see in the preceding screenshot by Item 1, we get an information message letting us know that we have yet to give any role the right to use the text editor. To address this, click the Permissions link.

Assigning User Rights via Roles

Within a Drupal site, individual users can be granted different roles. Within each role, the site administrator can assign different privileges. Some of these privileges relate to access control, while other privileges relate to accessing functionality.

Note

In Chapter 3, you created the teacher role. In this chapter, we will assign privileges to that role to allow teachers to access FCKeditor, and create assignments and teacher blog posts for the teacher blog as needed. Once these rights have been tuned, any user granted the teacher role will have the rights to run an effective teacher blog.

Understanding Roles and How They Work

In a Drupal site, role assignments are cumulative. If a user is a member of two or more roles, they have the collected rights of all of these roles.

Additionally, all users belong to the authenticated user role; this role is frequently used to establish basic rights for all users, with more advanced privileges being granted via other roles. In this site, we will only assign basic privileges to the authenticated user role. The majority of users of the site will belong to either of the teacher or student roles that we created in Chapter 3.

UndeFCKeditor, configuringuser rights assigning, via rolesrstanding Roles and How They Work

As pictured in the preceding screenshot, assign the authenticated user role permissions to access fckeditor. Assign the site admin role permissions to administer fckeditor. Click the Save permissions button to save the settings.

Then, when we return to the FCKeditor configuration page by clicking the Administer | Site configuration | FCKeditor link, or by navigating to admin/settings/fckeditor, we will have a new information message as shown in the following screenshot:

UndeFCKeditor, configuringuser rights assigning, via rolesrstanding Roles and How They Work

Editing the Advanced Profile

In this site, we will give all roles access to the Advanced profile. To adjust settings for the Advanced profile, click the edit link, as shown by Item 2 in the FCKeditor settings screenshot.

For most uses, the default profile settings will work perfectly. In this example, the only setting we need to adjust is in the Basic setup section.

Editing the Advanced Profile

As shown in the preceding screenshot, allow authenticated users to access this profile.

Click the Update profile button to save the changes.

Tip

The FCKeditor has many settings that can be adjusted, and addressing the full range of settings goes beyond the scope of this book. For more information, including links to both a Developer's Guide and a User's Guide, see http://docs.fckeditor.net.

Editing Visibility Settings in the Global Profile

We will want to make some changes to the FCKeditor Global Profile. To edit this profile, click the edit link as shown in the FCKeditor settings screenshot by Item 3.

We want to adjust the Visibility settings as shown in the following screenshot:

Editing Visibility Settings in the Global ProfileFCKeditor, configuringadvanced profile, editing

These settings determine precisely where the text editor will appear.

As shown in the preceding screenshot by Item 1, set the Use inclusion or exclusion mode to Include.

As shown by Item 2, delete all the values in the Fields to exclude/include text area.

As shown by Item 3, add three lines to the Paths to exclude/include text area:

node/add/*

node/*/edit

comment/*

Click the Update global profile button to save the changes.

These settings have the text editor showing up on all forms where a user is adding or editing content, or replying to a piece of content.

Editing Visibility Settings in the Global ProfileFCKeditor, configuringadvanced profile, editing

Additionally, the text editor can be enabled for specific fields by adding the field name into the Fields to exclude/include text area. The names of fields will be displayed to users who have the right to administer fckeditor; assigning these permissions is shown above, in the Permission screenshot.

Setting the Proper Input Formats

Input formats control the HTML tags and other text handling that people can use when creating content on your site. Setting your input formats is an essential part of running your site securely.

Note

Drupal allows you to grant some users permission to enter either PHP code or full HTML tags directly into a post. If these rights are granted at all, they should only be granted to a small number of very trusted users, as sloppy or malicious use of PHP code or certain HTML tags could compromise a site.

To set the Input formats, click the Administer | Site Configuration | Input formats link, or navigate to admin/settings/filters:

Setting the Proper Input Formats

As shown in the preceding screenshot, click the configure link for Filtered HTML.

Setting the Proper Input Formats

This brings you to the Filtered HTML input format page at admin/settings/filters/1. Click the Configure tab as shown by Item 1 in the preceding screenshot.

In the Allowed HTML tags field, as indicated by Item 2 in the above screenshot, enter the following list of HTML tags:

<a> <b> <blockquote> <br> <caption> <center> <code> <col> <colgroup> <dd> <del> <div> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr> <i> <img> <li> <ol> <p> <span> <strong> <sub> <sup> <table> <tbody> <td> <tfoot> <th> <thead> <tr> <u> <ul>

Click the Save configuration button to save your changes.

This list of tags is fairly permissive, and will allow users a great degree of freedom over the page layout. It will also work well with the text editor, and will not pose any security risks.

Note

Input filters exist for security reasons, and security is generally balanced against ease of use. This list does not contain any of the tags that can be used to run malicious code (a.k.a., hack your site), and using the above HTML tags you can create tables, change font appearance, and do many more things.

Tip

For a full list and explanation of HTML tags, look at the tag list from W3Schools: http://www.w3schools.com/tags/default.asp.

For an overview of HTML tags and security, visit: http://www.feedparser.org/docs/html-sanitization.html.

Now that we have enabled the FCKeditor and created a safe input format, we are ready to create the first two content types that will power the teacher blog.