Drupal

Insert a block programmatically with Drupal

Block is generated by a view

$block = module_invoke('views', 'block', 'view', <view_name not quoted: this is The unique identifier of the view>);

example:

$block = module_invoke('views', 'block', 'view', list_all_providers_cat_map);
print $block['content'];

The above does work for Drupal 5 but it doesn;t look like is working for Drupal 6 so you can just embed the view.

Assign Multiple Roles to User Programmatically in Drupal

$user = user_load(104);
 
$details = array(
		'uid' => $user->uid,
		'roles' => $user->roles
		);
 
$details['roles']['7'] = 'FREE ORDER';
 
user_save($user, $details);

Ubercart Credit Card Fields Not Showing at Checkout - Only Shows Loading Bar

Inside of Secure Pages Module,

add
cart/checkout/payment_details/credit
to your secure pages config

See this post for more details:
http://www.ubercart.org/forum/support/3380/failing_ajax_call_checkout_ssl

This also applies to any other payment method you have like:
cart/checkout/payment_details/other

Get the Current URL in Drupal

$path = isset($_GET['q']) ? $_GET['q'] : '<front>';
$link = url($path, array('absolute' => TRUE));

Content Archive with Previous / Next Article Links for Any Content Type

<?php     
    $type = "news";
    $foundArticle = 0;
	$nextNewsArticleTitle = '';
	$prevNewsArticleTitle = '';
	$nextNewsReleaseLink = '';
	$prevNewsReleaseLink = '';
	$prevNewsReleasePath = '';
	$nid = '';
	$nodeLink = '';
    $result = db_query("SELECT type,created,title,nid FROM {node} WHERE type = '%s' ORDER BY created ASC", $type);
        while ($data = db_fetch_array($result)) 
        {
            if($foundArticle == 1)	
            {
                $nextNewsArticleTitle =  $data['title'];
				$nid = $data['nid'];
				$nodeLink = 'node/'.$nid;
				$foundAr

Drupal 6 - Create a page.tpl for a View

Just found a cool trick . . .
You can create a template file to theme almost any aspect of views output. In your case you want to create a custom template for your page display.

On the view designer, click the Theme link in Basic Settings. You'll see some template file naming options depending on if you want to theme the whole view (e.g., views-view--example--page.tpl.php), each row (e.g., views-view-fields--example--page.tpl.php) and so on.

Copy the appropriate template you want to customize from /sites/all/modules/views/theme to your theme and customize as you wish.

Database Query the Drupal 6 Way

function referral_get_user($uid) {
  $referral_uid = FALSE;
  $result = db_query('SELECT referral_uid FROM {referral} WHERE uid = %d', $uid);
  while ($data = db_fetch_object($result)) {
    $referral_uid = $data->referral_uid;
  }
  return $referral_uid;
}

 
 
$nodeSrc = 'node/45';
  $result = db_query("SELECT dst FROM {url_alias} u WHERE src = '%s'", $nodeSrc);
 
  while ($data = db_fetch_object($result)) {
    echo $data->dst;
 
}
Placeholder | Meaning
%s | String
%d | Integer
%b | Binary
Syndicate content