If you want to have a link which hides or shows a paragraph this following snippit is pretty self explanitory and can be ran from a simple Drupal node or block using the PHP filter.

If you want to modify the user registration page, and only override a field's description like the email element, it can be done easily with the following code:

function myModule_form_alter(&$form, $form_state, $form_id){

  if($form_id == 'user_register')
  {
    // Change registration email description
    $form['account']['mail']['#description'] = t('MySite does not accept gmail,
    hotmail or similar accounts.  If you must use a gmail type account,
    please explain why in the Comments section, and we will consider your
    request.)');
  }
}

myModule is a custom module and you use the form_alter() hook implementation.  This allows you to ONLY modify the mail element and its associated #description property instead of the whole form.  Rather neat!

Drupal's Form API is powerful, but it's associated learning curve can be a steep one.  However, if you stick to these basic 5 steps you will be off to a good start in creating your own Drupal theme on the double.

The 5 basic steps to create a Drupal form using the API are as follows:

 

  1. A menu item
  2. A menu callback for that menu item
  3. Define the form
  4. Validate the form
  5. Re-direct or post-validation form submission

This document doesn't go into the basics of creating a module, but assues that you already possess that knowledge or can use Google.  This module is called basicform!

When creating a new block or altering an existing one, inside the block configuration interface, snippets of PHP code can be written to determine whether or not a block should be displayed.

 

Two of the most common snippets as follow:

Displaying a block to logged-in users only

Only return TRUE when the global $user is not 0.

<?php

global $user;

return (bool) $user->uid;

?>


Displaying a block to anonymous users only

Only return TRUE when the global $user is 0.

In my other tutorial, I covered how to create a rotating banner using CSS and a simple random PHP script.  This howto or tutorial covers creating a rotating banner or background using Jquery and a bit of CSS.

It is no more complex than the first method, but to get started you need the Jquery module installed.

Jquery is available here at: http://drupal.org/project/jquery_ui

Navigation
Syndicate
Syndicate content
Share this
Powered by Drupal, an open source content management system