Oz's picture

Drupal install database configuration page: no result or no error messages and page reloads

When trying to install Drupal and entering database credentials, the page just reloads with no error messages displayed. The problem is because the default.settings.php file was renamed instead of copied. You must copy this file and rename the copy.

Oz's picture

How to programmatically assign a user to a group

It took me a while to find some functions that can be used to programmatically assign a user to a group. So here is some functions, links, and details for anybody who wants to do something similar. These functions were a pain to find using Google, so here are some reference notes.

og_subscribe_user($groups = array(), $account = NULL, $replace = FALSE, $request = '')

This will subscribe a user to group, but membership must be approved.

Oz's picture

Importing MySQL database via command line

I always forget how to import a mysql database via command line, because I get used to using the phpmyadmin interface. But some databases are extremely large and the import will timeout. I find it easier and more convenient to use the command line to import the database, rather than change php.ini script timeout limit. A simple command like

mysql -u [username] -p[password] [database_name] < [path/to/file]

will do the trick in a timely fashion. I always forget the syntax so figured I'd post it as a quick reminder.

Oz's picture

A simple PHP zip function

function _zip($filename, $files=array()) {
  $zip = new ZipArchive();
  if($zip->open($filename, ZIPARCHIVE::CREATE)) {
    foreach($files as $file) {
      $dirs = explode('/',$file);
      $count = count($dirs);
      $filestr = $dirs[$count-1];
      $zip->addFile($file, $filestr);
Oz's picture

Calling node_delete from hook_cron doesn't delete node

When calling node_delete from within a hook_cron function, it will not delete the node because of the node_access call within node_delete. To make this work you must load a user who has permission to delete nodes.

global $user;
$user = user_load(1);

Oz's picture

Page Speed - A Firefox/Firebug Add-On

Google has created a very useful add-on for Firefox/Firebug that helps optimize performance of web pages. Just recently I have used it to optimize images on one of my sites. Page speed makes it easy to download the optimized versions of images which can then just be copied over the old unoptimized images. I also found that my css and javascript files were not combined. So I went to the Drupal performance page and enabled css optimization and javascript optimization. It is a great tool, and I am still playing with it to help me speed up my page loads.

Oz's picture

Sorting views columns that are node/user reference fields

I used to just slap views together using the cck content fields as column data. The problem I have found with this is you cannot sort the columns. To do so, you must use the relationships offered by views. So when adding a field, you choose node->title and choose the appropriate relationship. By doing this, you will be able to configure views to sort the columns .

Oz's picture

Changing theme to Pixture Reloaded does not load stylesheets

I recently changed a site from Pixture to Pixture Reloaded and all of a sudden there was just links, text, and white space .... no styles! I couldn't figure out why this was happening, so I cleared the cache which will sometimes solve this problem. This didn't work. I read somewhere that configuring the color scheme settings for Pixture Reloaded will fix this. So I changed the settings, and it worked. I changed from Pixture to Pixture Reloaded because it seems that Pixture doesn't display node titles.

Oz's picture

Download links to docx and xlsx are being presented to download as zip files in IE

I recently was running a site with file system settings set to private. I wanted to optimize css and javascript which requires the download method to be public. I knew this could cause problems on my site, so I changed it and tested everything on the site and all seemed good. I later found that using IE, some download links to excel files were not working and was trying to have me download odd zip files. I have a view set up for a content type that has title, body, and file field.

Oz's picture

Creating a new revision using node_save

When using node_save it might be useful to programmatically create a new revision or log a message on how the node was created. To do this is very easy. Simply add the following lines to your code:

$node = (object) NULL;
$node->type = "page";
$node->title = "Node Title";
$node->uid = 1;
$node->revision = 1;
$node->log = "Your log message here";

Syndicate content