How To

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:

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;

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;

Upgrade Drupal to 6.12

Just updated BobbyMods to 6.12.

I also updated a couple of multi-site installations, and if you didn't hack core and put the themes and modules where they should go (as opposed to where-ever it works) it should be fairly easy.

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

Updated Drupal to 6.11

Just updated BobbyMods to 6.11, and for the sites that I set up and manage it was an uneventful affair.

I also updated a couple of multi-site installations, and if you didn't hack core and put the themes and modules where they should go (as opposed to where-ever it works) it should be fairly easy.

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.

Syndicate content