php

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:

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.

Web-directory with OpenAds integration

Web-directory with OpenAds integration ProjectWeb-directory with OpenAds integration Project

Web-directory php script with ads as directory items or as directly viewable ads.

The ad serving is done with OpenAds.

Copyright block: a footer with php code in drupal

FootersFooters

Drupal has a nice feature to input a site wide footer message from the administration panel, it can be found at Administer>>Site configuration>>Site informationn  scroll down to Footer message:.

The only thing with this is that it is text only, and what you typically want is to be able to add some dynamic content in there.

One of the first thing you would want to do is to add a copyright notice to your site. Now, there is a module for nearly everything, and so there is this gem appropriately called  'Copyright'  which can set the copyright for the entire site and for individual  content pages.

There is a simpler way that, although manual, will help keep your install "light".

What I do is to just create a block, set the input format to "PHP code" and enter the following code:

<p>&copy; <?php print(date(Y)) ?> <a href="/"><?php print(variable_get('site_name', '')) ?></a><br />
All rights reserved
</p>

After that you can further customize when and where it will appear, if you need special formatting you can add css classes to it and enhance it's display as needed.

drupal copyright footer block

<p>&copy; <?php print(date(Y)) ?> <a href="/"><?php print(variable_get('site_name', '')) ?></a><br />
All rights reserved
</p>
Syndicate content