Node Import playing nice with Organic Groups
Out of the box the Node Import module doesn't play nice with the Organic Groups module. When trying to configure nodes to be posted into a group after the content import, two Drupal database tables are important: og_access_post and og_ancestry. The og_access_post table has two columns, nid and og_public. The og_public field should either 0 or 1 depending on whether you want the post to be public or not. The og_ancestry table also has two columns, nid and group_nid. After importing content, it is import to update these two tables with the appropriate data.
Function to retrieve a content type form array
.code {
background: #ffffd0; margin: 12px 12px 12px 12px; padding: 3px 3px 3px 3px;
}
//$form['#field_info'] contains information about cck fields
function _cck_form_array($type) {
module_load_include('inc', 'node', 'node.pages');
global $user;
$form_state = array();
$node = array('type' => $type, 'uid' => $user->uid, 'name' => $user->name);
$form = drupal_retrieve_form($type.'_node_form',$form_state,$node);
drupal_prepare_form($type.'_node_form', $form, $form_state);
return $form;
}
Node Import Tip
I was unable to import node reference fields that were autocomplete fields. To make this work, I had to change the node reference field to a select field. Then in the csv, use the Title of the node to import that reference. Also, when trying to import a field that is a single on/off checkbox, I wasn't able to import the on value. I kept receiving an invalid value error. To fix this I had to change the single on/off value to a regular select field.
Applying Drupal Patches in Windows
Download GNU Patch Utility
Navigate to module directory you are patching.
Type "patch -p0 < path/file.patch --binary"
Without --binary you will receive the message "Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354
This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information."
Removing orphaned actions
Use the url:
?q=admin/settings/actions/manage/orphan
to remove orphaned actions
How to setup WAMP to send emails over the Gmail smtp
This article explains how to setup WAMP to send emails over the Gmail smtp server using the PHP-function mail().
Software needed
Wamp - Download
Stunnel - Download
Sendmail - Download
Requirements:
Enable POP for your Gmail account (http://mail.google.com/support/bin/a...y?answer=13273)
Port 465 (or 587) must be opened to the internet (http://www.portforward.com/english/r...outerindex.htm)
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.
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 = '')
http://drupalcontrib.org/api/function/og_subscribe_user/6
This will subscribe a user to group, but membership must be approved.
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.
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);
}
}
$zip->close;
}
