Inserting HTML into node titles

Drupal strips all HTML from node titles when they're displayed to prevent XSS exploits. However, there are some cases where inline HTML elements are needed, such as when titles contain scientific names.

To work around this, we will use pseudotags like [i] and [/i] which Drupal will safely translate into real HTML tags when the page is displayed.

We need two new functions (please note that Drupal best practices are to include functions in template.php or a custom module; logic should not be placed in *.tpl.php).

function bb2html($text) {
  $bbcode = array(
                  "[strong]", "[/strong]",
                  "[b]",  "[/b]",
                  "[u]",  "[/u]",
                  "[i]",  "[/i]",
                  "[em]", "[/em]"
                );
  $htmlcode = array(
                "<strong>", "</strong>",
                "<strong>", "</strong>",
                "<u>", "</u>",
                "<em>", "</em>",
                "<em>", "</em>"
              );
  return str_replace($bbcode, $htmlcode, $text);
}

function bb_strip($text) {
  $bbcode = array(
                  "[strong]", "[/strong]",
                  "[b]",  "[/b]",
                  "[u]",  "[/u]",
                  "[i]",  "[/i]",
                  "[em]", "[/em]"
                );
  return str_replace($bbcode, '', $text);
}

Create a forum

Users can post topics to forums. Forums can appear below other forums in a hierarchy, or can appear in containers.

Mass URL aliasing

Drupal also comes with user defined mass URL aliasing capabilities. You might like to see completely different URLs used by Drupal, or even URLs translated to the visitors' native language, in which case this feature is handy. Only an administrator with access to the website source code can set up this kind of aliases. You can define a function somewhere in your code (even in settings.php), following this example:

Create forum containers

Containers are 'parents' for forums (discussion boards); they are used to group forums. Users cannot post topics to containers; users post to the forums in the container(s). A site with only a few forum discussion boards may not need any containers.

Overriding drupal.css; two approaches

There are two methods to removing drupal.css from your theme in phptemplate.

The first cuts out the link from the $head variable. In page.tpl.php, replace your print $head

print str_replace('<style type="text/css" media="all">@import "misc/drupal.css";</style>', '', $head);

The other method requires overriding the stylesheet import themable function. Simply add this to your theme's template.php file:

Installing using CVS repository

Development of the Drupal codebase is fairly quick, with a new release every six months or so. To help keep up with the pace of Drupal, using the CVS repository can be beneficial. This allows you to use the CVS command "cvs update" to download the current bug fixes and improvements.

To have the cvs functionality available to you, you will need to install the developer tools that were included on the OS X DVD. If you don't have them installed, or don't want to install them, you could always download Drupal directly and place the resulting directory inside the default OS X web server directory:

/Library/WebServer/Documents

To get started and to be consistent with the default Mac OS X setup, navigate to /Library/WebServer/Documents (from the Terminal command line):

cd /Library/WebServer/Documents

Download the version of Drupal that you want from CVS:

cvs -z9 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal checkout -r REVISION_NUMBER -d LOCAL_DIRECTORY drupal

Notes: The REVISION_NUMBER must match a specific Drupal CVS tag for the checkout to work. If you are wanting to download the Drupal 6.13 release, then the REVISION_NUMBER would be DRUPAL-6-13. A full list of the Drupal core CVS tags available to you can be found at http://cvs.drupal.org/viewvc.py/drupal/drupal/ in the Sticky Tag drop down menu.

The LOCAL_DIRECTORY is the name of the folder you would like to place the Drupal files into. This directory will be created if it does not exist already.

If, next week, a bugfix has been issued for this release, all that you would have to do is (again, from the Terminal command line):

cd /Library/WebServer/Documents
cvs update -dP

Pages

Subscribe with RSS Subscribe to RSS - Drupal 6.x