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:

* 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:

Copyright block: a footer with php code in drupal (The Module)

A follow-up on Copyright block: a footer with php code in drupal<.

I've had some requests to make this a module , so here it is, and there is nothing spectacular about it. It is just an example on how to make a simple block module.

Another question was if you could put drupal copyright footer block< in your theme. The answer is yes, but then you would not be able to switch it on / off or change themes as easy.

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;
Syndicate content