1-866-277-9958

PHP

Theme node body with a template file in the feature

This code can be used to add tpl.php files instead of implementing theme functions to your feature

<?php
 
/**
* Implementation of hook_theme().
* DRUPAL WONT SEE THIS HOOK UNTIL YOU CLEAR YOUR CACHE
*/
 
 
//Create myfeature-node-body.tpl.php in your feature and use $node to theme the node body
 
function myfeature_theme() {
  return array(
    'myfeature-node-body' => array(
      'template' => 'myfeature-node-body',
      'arguments' => array('node' => null),
    ),
  );
}
 
/**
 * Implementation of hook_nodeapi().
 */

Adding Customize Dashboard Magic to Your Drupal Theme

If you haven't already tried Open Atrium, you should immediately do so. Once you do, you'll want to put all their cool customize stuff into your website. While the documentation says that it uses context, spaces and features to accomplish their "whiz bang" features, they also use a few theme tricks to bind it all together.

I'm going to show you what is necessary to get your theme ready for the "Customize dashboard" functionality in openatrium.

Automated Logout with Drupal

Drupal, by default, does not support automated logouts based on inactivity. Thankfully, there is the "Automated Logout" module, which allows granular control of automated logouts. And for browser exits, there is a value you can set in your settings.php file.


Get Drupal help when you need it most! Find hundreds of great tutorials. Track, rate, comment and more. Create Account

If you enjoy our content, please consider subscribing through RSS, so you can read our posts in your application of choice.

How to add Yahoo! Tracking Code to your Drupal Site

More and more of our clients are wanting to track their site metrics from more than just google and since there aren't really any great modules for adding the Yahoo! tracking code; I thought I'd share exactly how I went about adding them. The problem is that if I simply place the tag on the page.tpl.php file then I get the code going site wide and if it's a conversion code, I only need it to trigger for certain pages. We tried creating individual pages and then placing the code in the body, but the problem is the Yahoo! code must be placed into the tags.

Drupal errors "Notice: Undefined index: profile in..."

Solution: 

Ah the joy of procedural programming in a weakly typed language.

There are two issues here:
1. Drupal is reporting notices
2. Datastructure mismatches

The particular above notice is created when php tries to access a index of an array where the variable is not holding an array. In general this notice will not cause problems with Drupal functionality. You may want to turn off php reporting notices. To do this you can change php's error reporting.

In php.ini use:
error_reporting = E_ALL & ~E_NOTICE

In .htaccess user:
php_value error_reporting 2039

How do I fix Drupal's fatal error for memory size exhausted?

Problem: 

Ideally, for a memory issue, you would want to change your php settings to increase php memory allotted. In the case of most hosting providers, you do not have permissions or the ability to change the php.ini file, so here is another option:

1. Log-in to your site via FTP
2. Locate the base install of your Drupal installation - often "www" or "public_html"
3. Open/edit the .htaccess file
4. Insert the following into the .htaccess file: php_value memory_limit 96M
5. Save the file and rewrite the .htaccess file on the server
6. Most memory issues should be resolved


Customizing the User Profile Layout in Drupal

As Drupal becomes more popular and grows its open-source development community, more websites are turning to it as a solution for creating extremely powerful online communities, allowing users to submit their own content to a community hub. The power of these hubs is obviously their users and creating an organized, easy to use interface can be the difference between failure and success.


Get Drupal help when you need it most! Find hundreds of great tutorials. Track, rate, comment and more. Create Account

Drupal Web site cutover checklist

I wrote up a doc detailing Drupal related stuff that needs to be done to launch a Drupal site. Here is the info for discussion and anyone who finds this useful.


Get Drupal help when you need it most! Find hundreds of great tutorials. Track, rate, comment and more. Create Account

Customizing the display of a node

Here is a 5-step process to have full control over the output of a node. This method lets you stay at the theme/display level and gives you full control over output without having to implement any hooks in a module. You'll often find that you can get the desired output without resorting to any PHP template or HTML coding using the first two steps.

First: Edit the order of fields

From the content type edit page, click on the Manage fields tab. The URL is admin/content/node-type/[mynodetype]/fields
From here, drag and drop the fields in the order you want them displayed.


Get Drupal help when you need it most! Find hundreds of great tutorials. Track, rate, comment and more. Create Account

Expose server side data from your module for client side javascript use

Adding the following code in any PHP area in Drupal will give you settings values available client-side that you can use when writing JavaScript code.

Pass a key/value associative array to drupal_add_js() and give it type value of 'setting'. Note that I am using an array of arrays with the key of the first array as the name of the module. This is to namespace the settings. This will keep your settings from overriding others and others from overriding yours.

//PHP code in your module or in a PHP snippet anywhere on your site
 
$jquery_settings = array(
  'myModule' => array(
    'mySetting1' => 'myvalue1', 
    'mySetting2' => 'myvalue2' )
);
drupal_add_js($jquery_settings, 'setting');


Get Drupal help when you need it most! Find hundreds of great tutorials. Track, rate, comment and more. Create Account
Syndicate content
Syndicate content

©1999 - 2011 LevelTen Interactive - Dallas, TX