Give me a break

Hi There! This text should be broken up nicely. For example: This was written on a new line! So was this! But everything got bunched up

The PHP evaluator simply causes posts to be sent for PHP processing, so that any code that falls between the PHP delimiters <?php and ?> gets executed properly. This should not be enabled for anyone other than yourself or a highly trusted administrator who needs it to complete his or her work. There is, however, no other work to be done for either of these options. The only additional settings we need to look at here are for the HTML filter.

Click on the configure tab at the top of the page in order to begin working with the HTML filter. You should be presented with something like this (once you have clicked on the HTML filter link to expand its content):

"HTML filter Filter HTML tags:

f* Strip disallowed tags

C Escape all tags

How to deal with HTML tags in user-contributed content, If set to "Strip disallowed tags", dangerous tags are removed (see below), If set to "Escape tags", all HTML is escaped and presented as it was typed.

Allowed HTML tags:_

|<a> <ern> <strong> <cite> <code> <ul> <al> <li> <dl> <dt> <dd>

If "Strip disallowed tags" is selected, optionally specify tags which should not be stripped. JavaScript event attributes are always stripped.

P" Display HTML help

If enabled, Drupal will display some basic HTML help in the long filter tips.

Spam link deterrent

If enabled, Drupal will add rel="nofollow" to all links, as a measure to reduce the effectiveness of spam links, Note: this will also prevent valid links from being followed by search engines, therefore it is likely most effective when enabled for anonymous users.

To start with, it is possible to decide, using the first two options, whether you would like to strip HTML tags that are disallowed, or simply ignore all tags from any posts (Escape all tags causes any tags that are present in the post to be displayed as is). Remember that if you strip all the tags from the content, you should enable the Line break converter so that users can at least paragraph their content properly. Which tags are to be stripped is decided in the following section, where you can enter a list of all the tags that are to be allowed—anything else gets removed!

In the previous screenshot you can see that there are eleven different types of tags allowed in this input format. Notice that the first one is in fact the <a> tag, which can be used to insert links into content—so be wary of this!

Following on, the next setting allows us to specify whether users are given HTML help when posting content—try enabling and disabling this option and browsing to this relative URL in each case to see the difference: filter/tips. There is quite a bit of helpful information on HTML in the long filter tips; so take a moment to read over those. The Spam link deterrent is a useful tool if you find that the site is being used to bombard members with links to products not sanctioned by you.

This is not the end of the story, because we also need to be able to create input formats in the event we require something that the default options can't cater for. In this case, let's assume that we want to add some picture files to the about us page, which we will create in due course. Now, there are several ways in which this can be done, but there are two main criteria that need to be satisfied before we can consider creating our page. We need to be able to:

1. Upload image files and attach them to the post.

2. Insert and display the image files within the body of the post.

We have already seen how to perform task number one when we discussed Upload in Chapter 4 on Adding Functionality. So assuming that you are able to attach files to your posts, this leaves us to deal with the second criterion. There are several methods for displaying image files within your posts. The one we will discuss here does not require us to download and install any contribution modules such as Imgassist. Instead we will use HTML directly to achieve this—specifically, we will need the <img> tag.

Take a look at the previous screenshot that shows the configure page of the Filtered HTML input format. You will notice that the <img> tag is not available for use. Let's create our own input format to cater for this instead of modifying this default option. Head on back to the main input formats page under administer and click on add input format. This will bring up the following page, from which you can build your new input format as shown:

input formats list add input format

Every filter performs one particular change on the user input, for example stripping out malicious HTML or making URLs clickable. Choose which filters you want to apply to text in this input format.

If you notice some filters are causing conflicts in the output, you can rearrange them.

|lnline Images

Specify a unique name for this filter format.


Choose which roles may use this filter format. Note that roles with the "administer filters" permission can always use all the filter formats.

V anonymous user

V authenticated user

V Forum Moderator user


Choose the filters that will be used in this filter format, F HTML filter

Allows you to restrict if users can post HTML and which tags to filter out.

F Line break converter

Concerts line breaks into HTML (i.e. -ibr> and <p> tags).

F PHP evaluator

Runs a piece of PHP code. The usage of this filter should be restricted to administrators only!

Save configuration

Since we will need to make use of some PHP code a bit later on, we have enabled the PHP evaluator option, as well as prevented the use of this format for anyone but ourselves—normally you would create a format for a group of users who require the modified posting abilities, but in this case we are simply demonstrating how to create a new input format; so this is fine for now.

Clicking Save configuration adds this new format to the list, and it can now be configured by clicking on the configure link adjacent to its name in the list in order to bring up its configuration pages. Now, the only difference between this input format and the default Filtered HTML in terms of HTML is the addition of the <img> tag followed by a space in the Allowed HTML tags list, as follows:

Allowed HTML tags:_

<img> <a> <ern> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <d

There is one other thing we need to look at before we are done with this input format. As things stand at the moment, we will run into problems with adding PHP code to any content postings. This is because at the moment the HTML filter has its way with the content first, and mangles the code for the PHP evaluator. What can be done about this?

Simply click on the rearrange tab when configuring your input format and give the PHP evaluator a lighter weight, as shown here:

'Inline Images' input format view configure rearrange

Because of the flexible filtering system, you might encounter a situation where one filter prevents another from doing its job, For example: a word in an URL gets converted into a glossary term, before the URL can be converted in a clickable link. When this happens, you will need to rearrange the order in which filters get executed.

Filters are executed from top-to-bottom. You can use the weight column to rearrange them: heavier filters 'sink' to the bottom.

Name Weight

PHP evaluator |0

HTML filter 110 jJ

Line break converter |1Q Save configuration

Now, the PHP evaluator gets dibs on the content and can process the PHP properly. For the purposes of adding images to your posts, this is all that is needed for now. Once that has been done, save the changes before using this to create the about us page. Before you do, though, it is probably most useful to have a short discourse on HTML since you will find that you need to be able to work with HTML as you attempt more complex postings.

SEO Made Easy

SEO Made Easy

Discover How To Get Your Sites On Top of The Search Engines So You Can Generate More Leads and Sales, Introducing... SEO Made Easy'. You'll discover why search engine optimization is important and why you should be optimizing are your pages so people can find your site.

Get My Free Ebook

Post a comment