Image for Dealpress
This is a guest post
How to override theme function in Drupal 6?
In your template.php, use hook_theme() API function to override the output of the theme.
As an example, we use the code below in template.php:
<?php/**** In this case, we are overriding user_login functions*/function yourtheme_theme() { return array( 'user_login' => array( 'template' => 'user-login', 'arguments' => array('form' => NULL), ), );}?>
Top 3 Drupal Modules for Developers
Here, I would mention top 3 Drupal Modules without which all Drupal development is waste and which makes Drupal development for most kind of applications a breeze without writing much of code. Writing lesser code also means lesser chances that your code would crash or not work.
The list to useful Drupal modules is almost endless and it is very difficult to find out important drupal modules, but there are 3 giants command on whom is must for every Drupal developer:
Drupal CCK:
Load Ubercart "add to button"
<?php$node = node_load(10);print theme_uc_product_add_to_cart($node);?>
How to Debug PHP code? How to debug some vague php syntax error?
I was getting the following error:[Wed Feb 04 08:09:30 2009] [error] [client xxx.xxx.xxxx.xxx] PHP Parse error: syntax error, unexpected '<' in /sites/all/modules/views/views.module(542) : eval()'d code on line 1 I wrote this code in view.module line 542 to debug: $result = eval($view->view_args_php);global $user;if ($user->uid== 1){
Embedding a content type node form with Drupal 6
How do you invoke or embed a content type node form in Drupal 6? Following code shows how to:
<?php global $user; $type = 'garden'; $node = array('uid' => $user->uid, 'name' => $user->name, 'type' => $type); module_load_include('inc', 'node', 'node.pages'); $form = drupal_get_form($type .'_node_form', $node); print_r($form);?>
Display all Drupal messages iin a nice transparent pop-up div or lightbox
<?php if ($messages): ?> <div id="TB_overlay" class="TB_overlayBG" onclick="tb_remove()"/> <div id="TB_window" style="margin-left: -165px; width: 330px; margin-top: -97px; display: block;">
Drupal 6 revisted: Passing arguments through filters in Views
<?php$view = views_get_view('view_name'); // fetch the view$display_id = 'default'; // chose the display type$view->set_display($display_id);$view->is_cacheable = FALSE;
Drupal 6: Embeding View in a block
function hook_block($op = 'list', $delta = 0, $edit = array()) { switch ($op) { case 'list': $blocks[0]['info'] = t('Example Block'); return $blocks; case 'view': default: $view = views_get_view('view_name'); $view->set_display('default');
Drupal 6 Views embeding and passing filters
Load a view: <?php$view = views_get_view('view_name');?> Initalize it and add arguments. Fiddle with options as needed:
