LevelTen Interactive

PHP

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.

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.

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.

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.

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');

Installing Essentials with XAMPP or WAMP

Solution: 

This appears to be a problem for all Drupal profiles, not just Essentials. As best I can tell, it's related to the Windows file system when the installer searches for modules in sites/all.

Greatly increase the max_execution_time php.ini. I would suggest 600 seconds. In XAMPP, php.ini is located at C:\xampp\apache\bin\php.ini. That is the only location that matters. Changes to other php.ini files will not have any effect.

Install Essentials.

After the initial install, you will be able to reset the max_execution_time to what it was originally (usually 30 seconds) and the site will work properly.

How to keep osCommerce Session ID's on non-store pages.

Solution: 

Instead of using the standard link convetion: <a href="new-page.php">

Use the following format: <a href="<?=tep_href_link('new-page.php')?>">

If you really want to get creative and are looking at SEO specifically you can create custom pages for each product category by copying the index.php page and saving it as new-category-specific-index.php page. This page will function just like the default index.php page in osCommerce, to have the page return only the specific category you need, you'll need to use the following code:
<a href="<?=tep_href_link('new-category-specific-index.php','cPath=28')?>">

Remember to change the cPath=28 to the actual desired category or you'll get all the products.

Syndicate content
Syndicate content

©1999 - 2010 LevelTen Interactive - Dallas, TX