Deprecated

Customizing the full page layout and sections using CSS and unique BODY Class & IDs

description

This explains how to control the entire page layout depending on the node type using CSS styles.

Thanks to Zach Harkey for submitting the original snippet.

This snippet works with Drupal 4.5, 4.6 and 4.7.

usage

This snippet will create a body class and id for every page on your site. An example application might be for adjusting a fixed width layout when you use the administrative options.

Using this snippet, when you go to to admin/themes, for example, you may use the following style hooks in your style sheet to control how the full page looks.

<body class="section-admin" id="page-admin-themes">

In your style sheet (the CSS file in your active theme folder), you simply add another line to change the layout when you click on the ADMINISTER menu:

.content { width="744px" }
.section-admin .content { width="100%" }

Step 1 of 2

  1. make a backup copy of your page.tpl.php file.
  2. using a text editor like notepad.exe or equivalent, replace the <body <?php print theme("onload_attribute"); ?>> line with the snippet below in your page.tpl.php file
  3. upload your edited page.tpl.php layout file to your active theme folder

Customizing the full page layout and sections based on node type

If you are using Drupal 5 or 6, follow the directions on this page instead: Different page templates depending on node type

Description

This explains how to customize the entire page layout depending on the node type. An example application is if you wanted your entire blog pages to look different to your book pages.

Usage

As an illustrative example, the following step-by-step approach shows you how to setup different (full) page layouts for your blogs, books and the front page to your site.

Step 1 of 2

  1. Make a copy of your page.tpl.php file and rename it to be page-default.tpl.php.
  2. Make further copies your page.tpl.php file it and rename them to be page-front.tpl.php, page-blog.tpl.php and page-book.tpl.php etcetera..
  3. Using a text editor like notepad.exe or equivalent, modify the layout of each tpl.php file to suit your desires
  4. Upload your new page-type.tpl.php layout files to your active theme folder

Step 2 of 2

  1. Using a text editor like notepad.exe or equivalent, replace the contents of your page.tpl.php file with the snippet below
  2. Ensure that you have a page-default.tpl.php file as part of your collection of layouts.

User Invite

Last modified: October 16, 2008 - 19:57

This module is unmaintained. For another choice see the Invite module.

The user invite module is used to invite people to register and create a user account on your site. This is useful for social networking and online groups where the value of the site increases with the more users that join.

The user invite module is dependent on the Invite API module.

You can:

  • enable the user invite module at administer >> modules.
  • download the latest version on the User Invite CVS page.

Views Module Developer API

Last modified: September 24, 2009 - 12:35
NOTE: This page is deprecated.
Please, see http://drupal.org/handbook/modules/views/api for the current page.

To be documented:

  • the extra element in views_tables is undocumented
  • hook_views_query_substitutions
  • style plugins may return $query and $countquery elements
  • hook_views_pre_view: alter returned data before it is rendered
  • hook_views_post_view: alter the output string after render

The most important aspect to the Views system is that any module can expose its tables to the Views module. It can select which fields can be sorted on, filtered on, and viewed in the table format. It can expose fields to be used as URL arguments to a view. And it can define default views which are exposed to the admin and may be overridden, modified or otherwise customized.

Hooks and Handlers

You have to tell Views about your tables using a hook. Views offers 3 hooks:

   
    hook_views_tables();
    hook_views_arguments();
    hook_views_default_views();

Clearing Drupal's cache

Last modified: September 10, 2009 - 07:37

You may need to clear caches after moving your site from one host to another. Also useful when you install new modules or for troubleshooting things. It is relatively harmless. Your site might slow down a bit after-wards while the cache fills back up.

A php snippet

You will never lose irretrievable data with this query. Use it as needed.

<?php
db_query
("DELETE FROM {cache};");
?>

The Devel Module

The devel module makes it easy to clear Drupal's cache. Just install the module and enable the developer block for easy access to cache clearing.

The Admin_menu module

The admin_menu has many time saving features, including several cache clearing options for menu, page requisites, theme registry, cache tables and administration menu. It also has cron and update.php links too.

How to split the results into separate pages if the snippet returns lots of results

Last modified: August 27, 2009 - 00:09

Creates a paginated list of node titles of a specific type, within x days of today with a link to each node.

<?php
/**
* Creates a paginated list of node titles of a specific type, within x days of today
* with a link to each node.
*
* To change which type is listed, simply edit the $node_type string.
* To change the amount of results per page, edit the $list_length variable.
*
* This works with both Drupal 4.6 and Drupal 4.7
*/
$node_type = "image";
$time_lapse = strtotime("-50 days");
$list_length = 25;
$start_stamp = date("Y-m-d", $time_lapse);
$end_stamp = date("Y-m-d");
$start_stamp = strtotime($start_stamp);
$end_stamp = strtotime($end_stamp);
$sql = db_rewrite_sql("SELECT n.title, n.nid FROM {node} n WHERE n.created < %d AND n.created > %d AND n.type = '%s'");
$result = pager_query(sprintf($sql, $end_stamp, $start_stamp, $node_type), $list_length);
while (
$anode = db_fetch_object($result)) {
$output []= l($anode->title, "node/$anode->nid");
}
print
theme('item_list', $output);
print
theme('pager', NULL, $list_length);
?>

Same as before, if you wish to give the list a title then change print theme('item_list', $output); into print theme('item_list', $output, 'Node Titles');

Syndicate content
 
 

Drupal is a registered trademark of Dries Buytaert.