If you are looking at this page, chances are your looking to modify or customize the Drupal login/registration pages. Have no fear - there are a few easy ways to accomplish this.
- Create a page-user-login.tpl.php file
- Create a small user-login.tpl.php template file AND create a theme function.
Personally, I feel the later theme function is easier to manipulate and is cleaner to implement.
I had done some reading on this and I took glimmers of information from these two sites:
- http://www.caspianit.co.uk/drupal-6-custom-login-form
- http://picxelplay.com/blog/theming-drupal-6-registration-login-and-reque...
Lets get started:
In your Drupal theme, create a file called template.php if there is not one already. Modify the existing one if there is.
Add a function that looks like the following and replace 'mytheme' with your theme's name:
function mytheme_theme($existing, $type, $theme, $path)
{
return array('user_login' => array('template' => 'user-login','arguments' => array('form' => NULL))
);
}
Save the template.php file.
Installing Drupal can be rewarding and easy. This howto assumes that you already have a Fedora 12 installation configured with both SE-Linux, Firewall active and minimal services/packages. This tutorial is for beginners so that they can get Drupal installed quickly and easily. It also guides users through installing Webmin and phpmyadmin.
Anyone can create a website these days or purchase a template, but what truely makes your business or website a success?
Often branding shops or design firms sell beautifully taylored mockups that look great as an image, but can be difficult to implement. However, before implementing a website you will probably need a content management system (CMS) to organize content and provide additional functionality a static website cannot.
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.
Using jQuery with Drupal is straightforward and of course jQuery in my opinion lives up to its name, write less and do more. The following code is an example of how to perform a simple jQuery script onto a particular CSS ID assigned to a paragraph tag.
Create a new node, enable the PHP filter and place this code into the node.
<?php
drupal_add_js(
'$(document).ready(function(){
// Hide all the paragraphs.
$("p").hide();
// Fade them into visibility
$("#one").fadeIn("slow");
});',
'inline'
);
?>
<p id="one">Paragraph one</p>
<p>Paragraph two</p>
<p>Paragraph three</p>
This code will affect all of the paragraphs, but for a particular tag or ID use this code:
$("#one").fadeIn("slow");
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:
- A menu item
- A menu callback for that menu item
- Define the form
- Validate the form
- 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
