Advanced custom login form

description

These snippets allow you to override the default login layout using a custom user_login.tpl.php and control each element of the login form.

If you want to customise the full page layout, click through to the Customising the login, registration and request password full page layout handbook page.

Step 1 of 2

In a text editor like notepad.exe, create a file called template.php using the the following snippet. If you already have a template.php file, simply add it to your existing one (remembering to omit the opening and closing PHP tags).


<?php
/**
* This snippet catches the default login form and looks for your
* custom user_login.tpl.php file in the theme folder
*/
function phptemplate_user_login($form) {
$form['pass']['#description'] = 'password';
$form['name']['#description'] = 'username';
$form['name']['#size'] = 10; // change the size of the username form box
$form['pass']['#size'] = 10; // change the size of the password form box
$form['submit']['#value'] = 'Log in'; // change the login button text.

return _phptemplate_callback('user_login', array('form' => $form));
}
function _phptemplate_variables($hook, $vars) {
global $user;
switch($hook) {
case 'page' :

Can drupal be used for a tourism operator?

A non-technical colleague is looking for a tourist operator solution. I showed him drupal and it seems to be ideal for his online CMS requirements, but he's unsure about drupal being usable for his e-commerce needs:

How to Customize the Block Search Form

Description

This describes how to override the default BLOCK Search Form* theme, button and features in template.php.

* The BLOCK Search Form is the search form available through 'Blocks' and it can be placed in any block region. This is DIFFERENT from the THEME Search Form (see notes below for overriding THEME Search Form.

Assumptions:

  • Search Module is turned on.
  • You are printing the search box from your 'Blocks' and have enabled/placed it in a region.

Changing the site logo and name for each section based on path

description

This snippet allows you to override the site logo and site name for sections of your site, based on paths.

Drupal 5 Implementation

As an illustrative example, the following step-by-step approach shows you how to switch the site logo and site name for when users are viewing various sections (based on path)

Step 1 of 1

  1. Using a text editor like notepad.exe or equivalent, paste the snippet below into your template.php file.
  2. Edit the path arguments to suit your needs
  3. Upload your edited template.php file to your active theme folder and your new layouts will take effect automatically


<?php
/**
* This snippet overrides the logo and site name when users
* are viewing certain sections of your site.*/

function _phptemplate_variables($hook, $variables = array()) {
switch ($hook) {
case 'page':
if ((arg(0) == 'blog')) {// changes the logo and site name when viewing blogs
$variables['site_name'] = 'blog section name'; // change the site name
$variables['logo'] = '/path/to/newlogo/logo.png'; // change the site logo
}
if ((arg(0) == 'image')) { // changes the logo and site name when viewing images
$variables['site_name'] = 'user section name'; // change the site name

Customizing the site logo and name based on path

description

This snippet allows you to load a custom layout file and override the site logo and site name based on path.

Thanks to thomasmurphy for contributing the original snippet.

usage

As an illustrative example, the following step-by-step approach shows you how load a custom blog page layout file and switch the site logo and site name for when users are viewing blogs.

Step 1 of 2

  1. make a copy of your page.tpl.php file and rename it to be page-blog.tpl.php.
  2. Using a text editor like notepad.exe or equivalent, modify the layout of page-blog.tpl.php file to suit your desires
  3. Upload your new page-blog.tpl.php layout file to your active theme folder

Step 2 of 2

  1. Using a text editor like notepad.exe or equivalent, paste the snippet below into your template.php file.
  2. Upload your edited template.php file to your active theme folder and your new layouts will take effect automatically


<?php
/**
* This snippet loads a custom page-blog.tpl.php layout file and
* overrides the logo and site name when users
* are viewing blogs.
*/

function _phptemplate_variables($hook, $variables = array()) {
switch ($hook) {
case 'page':

Admin and Edit/Add theme switcher using your template.php file

description

These snippets automatically switches your theme to a custom page-admin.tpl.php layout file so a custom administrators theme is activated when needed.

Useful if you're using a fixed-width site design and your administration pages breaks the layout or where you want to add editing tips to where the sidebar blocks normally appear when a user is creating/editing content.

Pages

Subscribe with RSS Subscribe to RSS - Drupal 6.x