Archive for the ‘Frontend Design’ Category

Drupal theme variables

Thursday, March 11th, 2010

How to use Drupal theme variables?

Add the following codes into themplt.php

<?php
yourthemename_preprocess_page(&$variables) {
$variables['happyday'] = 'Happy ' . format_date(time(), 'custom', 'l') . '!';
}
?>
And display the variables in page.tpl.php:
<?php
print $happyday;
?>

Drupal theme block display issues

Thursday, March 11th, 2010

Complex themes have many different block regions, some regions will only appear on certain pages or when viewing nodes of certain types. One very common use-case is to have both a page.tpl.php, and a page-front.tpl.php, each of which print out different regions.

How to define block regions in Drupal? Simply add a couple lines in your theme’s .info file:

regions[ad_top]        = Ad Top
regions[ad_bottom]     = Ad Bottom
regions[front_sidebar] = Front Sidebar
regions[sidebar_ad]    = Sidebar Ad
regions[content]       = Content
regions[feature_a]     = Feature A
regions[feature_b]     = Feature B
regions[feature_c]     = Feature C
regions[feature_d]     = Feature D

And then in your *.tpl.php file, wherever you want the region to appear, simply print out its machine-readable name.

<?php
print $feature_a;
?>
Setting the block’s visibility settings (on the block’s configuration form) to not show up on pages that do not have the region it’s assigned to printed. For example, setting any blocks assigned to the Feature A region to only show up on the <front> page.
Hiding the visibility of the block by some other means; for example, by limiting it to a role using the checkboxes on the block configuration form (or content types in Drupal 7), or installing a contributed module that implements hook_db_rewrite_sql() on the block list.
Block Page Visibility is used to set block visibility for each page. Or use Context module to control the render of blocks.

Bug of background image in an inline list in IE8

Sunday, January 10th, 2010

Also see http://www.v7n.com/forums/web-design-lobby/115171-background-image-inline-list-ie.html

FF/IE hacks:

padding: 2px 0 2px 18px; /*FF LTR */
padding: 12px 0 2px 18px\9; /*IE8 LTR */
+padding: 2px 0 2px 18px; /*IE7 LTR */
_padding: 2px 0 2px 18px; /*IE6 LTR */

Protected: urls

Thursday, December 10th, 2009

This post is password protected. To view it please enter your password below:


Simple usage of ajax json in drupal

Thursday, October 22nd, 2009

//add the client side js
function hook_init()
{
drupal_add_js(‘$(document).ready(
function(…){});
‘,’inline’);
}

//server side callback
function my()
{
drupal_set_header(‘Content-Type: text/plain; charset: utf-8′);
$output = ”;

echo json_encode($output);
}