FAQ

Drupal

Added some php code to a block that broke my site with errors, how do I recover?

To disable this block if your site is unusable;
Log on to your mysql drupal database.
Go to the "blocks" table and find the offending block.
Change the "status" field of that block to '0' and clear the cache tables.

You could also remove the code from the corresponding boxes table (bid) or set the block input filter to html instead of php (format filter 1 or 2 in the boxes table).

If your site is broken but you can still log in and make changes;
Log in and disable, delete or modify the block that breaks your site.

Can I change the blog look of a drupal site?

Yes you can change the look of a drupal site to whatever you like with theming.

Also have a look at Drupal Showcase.<

How can I embed video in a drupal post?

The easiest and simplest way to embed video in a drupal post is by just copying and pasting the embed video code into the content you are making.

What you have to be careful about is the "input filter" you select for your content, most times the "Filtered HTML" filter will simply not display your embedded code, and the "Full HTML" filter will allow your embedded video code to be displayed and show your embedded video.

Of course if you have 'toyed' around with your input filters you have to make certain that the selected input filter allows the html code that is used to embed the video.

If your video embed code is javascript then you will need to enable the PHP Input module and select the php input filter for your video to show up.

As with all things drupal, there's also at least one module for this;

The SWF Tools is the most prominent at the moment (may 2009). For others just search the media modules section at Drupal.org

Is a drupal site something that users can update themselves once the site is ready?

Yes, with sufficient permission, users can update the site, and if some WYSIWYG text editors are installed, It will be as if they were editing a document on their pc.

Drupal Modules

How do I add my own PHP functions to Drupal

When you need to add your own php functions to drupal, you can simply embed them in the content, but that is not the best way.

The best way to add your own PHP functions to Drupal, would be to create your own function library module.

Lets hypothetically call your PHP function library "myfunctionlib", you will need to change that everywhere to reflect your own naming convention.

To create the PHP function library module first create a folder "myfunctionlib".

In that folder create a file called myfunctionlib.module with the following content:

<?php
/**
* Function Description
* @param function_parameter
* @returns function output description
*/

function myfunctionlibone($type="page") {
// php function code
}
function myfunctionlibtwo($show="list") {
// php function code
}
//don't close with ?>

In the same folder create another file called "myfunctionlib.info" with the following content:

name = My Function Library
description = This module contains my PHP helper functions.
core = 6.x
package = "MyFunctions"

version = "6.x-X.X"

"core" tells Drupal with which version of drupal the module works.
"version" tellds drupal what the version of this module is.

Upload the module folder "myfunctionlib" to the "sites/all/modules" folder, enable it on the modules administration page and call it where you want to use your php functions with;

<?php myfunctionlibtwo("block"); ?>
Don't forget to install and enable the PHP input filter if you have not done so already.

For more information on creating modules, coding standards, etc., see the Module developer's guide.

How to install a module?

To install modules in order to customize your Drupal install:

  1. Download the module. Make sure the version of the module matches your version of Drupal. It will appear in a compressed file format such as 'tar.gz'.
  2. Read the install instructions. If the module has an installation file (usually INSTALL.txt and/or README.txt), read it for specific instructions.
  3. Upload the module. There are 2 possibilities here, use one;
    1. You DON'T have a control panel(cpanel /plesk) with "file manager". In this case extract the module folder from the compressed file and upload the module folder to sites/all/modules< (use FTP).
    2. You have a control panel(cpanel /plesk) with "file manager". In this case upload the compressed file to sites/all/modules< and extract it there with your "file manager".
  4. Enable the module. Go to Administer > Site building > Modules. Check the 'Enabled' box next to the module and then click the 'Save Configuration' button at the bottom.
  5. Set file permissions.Some modules require permissions to get them working. Permissions info should be in the instructions that came with the module. If needed, go to Administer > User management > Permissions (Drupal 5: Administer > User management > Access control). If the module appears in the list give the appropriate permissions to desired roles.
  6. Adjust settings. Most modules will have some type of settings page. It should be described in the README.txt file. To locate a module's settings page try navigating to "admin/by-module" and see if the module appears in the list. If it does, it's settings page(s) will be listed also.

If you run into problems, search the module's issue queue and the forums. If your problem hasn't already been addressed, post a question, issue or contact the module maker.

See also Installing contributed modules<

Drupal Theming

How do I make a drupal theme from my html page.

If you already have a html file from your design, and are using stock drupal, then the info on these pages (Convert any website layout or template into a Drupal theme - easily! and Assigning content to regions) of the theming guide will get you along.

In short, there are the following regions;

  • left
  • right
  • content
  • header
  • footer

Drupal outputs this content in

  • $left
  • $right
  • $content
  • $header
  • $footer

So if you place a <?php print $left ?> (or any other one) in you html layout will output 'left' content to your design.

There are other additional strings that are output so just make sure you put those in your html (Check out a page.tpl.php, to get an idea).

How to get your html to initially display without making a whole theme? Just copy the relevant pieces of your html design to a (copy) of page.tpl.php.

...and read the Theme Guide.