Blogs
Load Ubercart "add to button"
<?php
$node = node_load(10);
print theme_uc_product_add_to_cart($node);
?>
- programmer's blog
- 1 comment
- login or register to post comments
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){
- programmer's blog
- Read more
- login or register to post comments
Embedding a content type node form with Drupal 6
<pre>
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);
</pre>
- programmer's blog
- login or register to post comments
Display all Drupal messages iin a nice transparent pop-up div or lightbox
<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;">
- programmer's blog
- Read more
- login or register to post comments
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;
- programmer's blog
- Read more
- login or register to post comments
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');
- programmer's blog
- Read more
- login or register to post comments
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:
- programmer's blog
- Read more
- login or register to post comments
Performance Improvements in Drupal
The posting I made on drupal.org (http://drupal.org/node/346838):
Usage of complex CCKs does come at a performance cost, since, the tables are not optimized.
I have worked on Drupal performance and could get quite exceptional results with few of the techniques for some of the clients. Here are couple of things, that would make your Drupal site run quite fast:
- programmer's blog
- Read more
- login or register to post comments
How to debug in Drupal using drupal_set_message and come to the exact line that is causing the error?
Put the following code snippet in includes/bootstrap.inc in the drupal_set_message function.. .
<code>
if ($type == 'error') {
$message .= '<pre>'. print_r(debug_backtrace(), 1) .'</pre>';
}
</code>
- programmer's blog
- login or register to post comments
How to override node-xxx-edit.tpl.php in drupal 6
Could not find a proper solution yet. But, the temporary one goes here:
function custom_nodeapi(&$node, $op, $a3 = null, $a4 = null) {
switch ($op) {
case 'load':
break;
case 'prepare':
if ( arg(2) == 'edit' ) {
$form = theme('article_edit', $node);
}
break;
}
}
In template.php
function theme_article_edit($form) {
return _phptemplate_callback('article_edit', array('user' => $user, 'form' => $form));
}
- programmer's blog
- login or register to post comments