Friday, December 16, 2011

My current sites/all/modules

My current "modules" folder and what it contains:

  • civicrm
  • contrib
  • custom
  • shortsitename_features
I kind of like that.  Nice and sweet.  There's a bunch of modules under "contrib" of course, a few under custom (but growing) and a few under shortsitename_features  (but growing).

Tuesday, December 13, 2011

CiviCRM - moving your configuration changes to a different environment

I love code driven development.  So when I build my Drupal sites, I immediately download and enable Features.  I do not want to handle website settings between environments by comparing screens and clicking box after box.  When you are running in a local DEV environment, plus you have a TEST and LIVE environment, using Features saves time (which of course equals money).

So I started a new project using CiviCRM and the thought in the back of my mind for awhile was:

"I just changed a CiviCRM setting.  How do I migrate that change to my TEST and LIVE environments?".  

Well the time came and I had to do it.  I needed to get my TEST site going and didn't want to bother remembering all of the settings I needed to configure.

Luckily, CiviCRM comes with migrate scripts to Export and Import your settings.

First Export it from the localhost (DEV environment) using one of the options.  More exist, but these are pretty basic:

  1. Browse to
    1.  http://localhost/virtual_dir/sites/all/modules/civicrm/bin/migrate/export.php?name=&pass=&key=
      1. This will download a file called CustomGroupData.xml
  2. Using wget (if you want to script this and update the file at 3pm for example)
    1. wget -O D:\dev\htdocs\virtual_dir\sites\default\CiviCRM.info "http://localhost/virtual_dir/sites/all/modules/civicrm/bin/migrate/export.php?name=&pass=&key="


I save this file to a folder in the website I am working on.  Then, if it has changed, I commit it to git.

After the export file has been committed to git, then moved to your next server, import:
http://example.com/sites/all/modules/civicrm/bin/migrate/import.php?name=&pass=&key=&file=../../../../../default/CiviCRM.info


Notice the difference between this command and previous ones is that it uses import.php and specifies a file.

I noticed there were a couple of settings that did not get exported and I think those are related to CiviCRM Profiles.  I need to look into this a bit and see if this is an issue or "works as designed".

What are some other options for moving CiviCRM configuration changes between environments?

Monday, November 7, 2011

Drupal - Code Driven Development

I think most of my sites have 2 versions...LOCAL and LIVE to allow testing of various changes as well as developing new themes and modules. Some sites have 3 versions, LOCAL, USER TEST, and LIVE.

I like having a local version so that I can polish it first. Also, I use tools like NetBeans for coding and debugging.

I use "Code driven development" for all my Drupal sites. Remember, the changes you are making through the GUI in your Drupal site are being saved to the database.  To use code-driven development, you need to get those changes out of the DB and into code.  This is where Features comes in.  My process:
  1. Develop code or theme; make your config changes in Drupal
  2. Export as much as possible using Features and Strongarm - This puts the DB changes into code
  3. Checkin the code to your version control system
  4. On the server - pull code from your repo
  5. Enable the various Features
Once you have your systems and procedures in place, this can actually be a time saver.  It's actually quite fun!!!! :)

Debugging PHP in NetBeans (in Ubuntu)



Here are the steps I used to setup PHP debugging in NetBeans (6.8 at the time of this writing) in Ubuntu 10.

sudo apt-get install php-pear
sudo apt-get install php5-dev
sudo apt-get install php5-xdebug



Edit your PHP INI settings
sudo nano /etc/php5/apache2/php.ini

Add the following lines under extensions:


zend_extension=/usr/lib/php5/the-folder/xdebug.so
xdebug.remote_enable=on


In my case it was ""/usr/lib/php5/20090626+lfs".  You will have to find the xdebug.so file in the correct folder.

Restart Apache
sudo /etc/init.d/apache2 restart


NetBeans PHP Debug Settings
  1. Goto tools->Options
  2. Select PHP
  3. On the General tab
  4. If this is your first time configuring xdebug, you may want to keep "Stop at First Line" checked.  this way when you start debugging you should know right away that your setup is correct. 
Start Debugging
  • Add some break points.
  • Right-click your project and select Debug

Thursday, October 13, 2011

CentOS 5.6 server setup

These are the guides and blog posts I use to setup LAMP on my new CentOS servers:



I typically install Webmin too, so I'll document that one in a bit.

Thursday, October 6, 2011

Drupal 6 "Unable to fetch any information about available new releases and updates"

When manually trying to check for available updates I ran into this message:

"Unable to fetch any information about available new releases and updates"

I don't recall ever seeing this when running Drupal 6.

My solution: restart Apache and it worked.

http://drupal.org/node/168828

Thursday, September 29, 2011

Updating modules and themes requires FTP access to your server

How to get rid of that pesky (D7) FTP issue when updating modules:

Updating modules and themes requires FTP access to your server

http://drupal.org/documentation/install/modules-themes/modules-7#comment-4690140

The short of it, change the owner of the sites/default directory to whoever the Apache default user is (www-data, apache, etc.)

chown www-data sites/default

Monday, September 19, 2011

Debugging PHP in NetBeans (in Windows)


Here are the steps I used to setup PHP debugging in NetBeans (7.0 at the time of this writing).

The way to do it:  http://xdebug.org/docs/install
You will need to download the correct php_xdebug from the xdebug.org site: http://xdebug.org/download.php

I downloaded the correct DLL for my environment and followed the install instructions.  Below are my final php.ini settings:

This extension is disabled
;extension=php_xdebug.dll


[XDebug]
;; Only Zend OR (!) XDebug
;zend_extension_ts="D:\xampp\php\ext\php_xdebug.dll"
zend_extension_ts = "D:\xampp\php\ext\php_xdebug-2.1.1-5.2-vc6.dll"
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.profiler_enable=1
xdebug.profiler_output_dir="D:\xampp\tmp"


NetBeans PHP Debug Settings
  1. Goto tools->Options
  2. Select PHP
  3. On the General tab

Friday, September 2, 2011

Almost 3 Years!!!

Hey look, I've been a member of D.O for nearly 3 years now.  :)


Thursday, September 1, 2011

Drupal 6 - Remove N/A from list of Radio button options

When creating a radio button field with CCK, you can remove the "N/A" option by making the field required.

fyi...to make your options turn into checkboxes, change "Number of values" to something other than 1.

D6 - SIMPLE module to get JavaScript working on a form

The very quick and easy way to get some JavaScript working on your form:

  1. Add the 3 files below to your basic module structure.  This module is called "your_module" for example purposes.
  2. Enable the module
  3. Clear cache

your_module.info:
name = Demo Information
description = Custom handling of demo information
core = 6.x
package = Your Company


your_module.module:
<?php

/**
 * Implementation of hook_form_alter().
 */
function your_module_form_alter(&$form, $form_state, $form_id) {
  // Only include on WHATEVER node add/edit forms.  Adjust these lines based on your content types.
  if ($form_id == 'new_item_node_form') {
    drupal_add_js(drupal_get_path('module', 'your_module') .'/your_module.js');
  }
}


your_module.js:
alert("Gotcha!");



Look at the HTML source and you should see your_module.js listed within all the other JavaScript files.

Wednesday, August 17, 2011

Using Git with a central repository

This is a nice write up on using Git with a central repository.  A good tutorial for newbies to Git.

Friday, August 12, 2011

Migrating User Guides

So you've got that awesome functionality built for your Drupal site...but the user doesn't know how to use it.

Welcome to Books and "User Guide Migration". For Drupal 6

How this came to be for me:
I needed to create some user guides, so I thought Book.  I needed this to run on a TEST server, because the users were learning here, and the LIVE server was not setup yet.  I needed to be able to migrate this content to the LIVE server without having to copy and paste.  I could not find a usable book export and import tool.  None of the ones I tried worked very well.  I tried the method below and was up and running in less than an hour (maybe it was less than 30 minutes...I don't remember).

First we need the modules:
  1. Book (standard in Drupal, but needs to be enabled)
  2. Deploy
  3. Services
At this point it is important to setup the Deploy and Services modules correctly.  I say correctly because the first time I did this, it didn't work.  The initial reason was that I used Drush to download the modules and I ended up getting a wrong version.  I believe I had to manually download and install the correct Services module to match Deploy.  Reading the documentation in the link above will get you the correct versions.  This was the only issue I came up with, but that was my fault.  :)

Reading the rest of the documentation will get your deployment and live server setup.  You need your deployment plan on your source server as well as authentication.  You also need authentication setup on your destination server.

Now create your book.  I won't go into the details about making a book, just add pages and modify the outline when necessary.
  1. Add your pages
  2. Change the outline where necessary
Now we are ready for pushing the content to your destination (LIVE) server.  You have your book setup on your source (or DEV or TEST) server or wherever, and now you need to go LIVE with it.

  1. Open the book, and you should see the option of Deploy. Select this.
  2. Select the Deployment Plan. In this example I am selecting the plan that was previously created.
  3. If successful, you should see a list of pages that are setup in your deployment plan.
  4. Repeat this process for EACH page in your book.  It's very easy to step through the book and then open the Deploy page in a new tab and do Step 2 later.

Now, you need to PUSH to your destination (LIVE) server.
  1. Go to Site Building,  Deployment, and you should see your list of deployments
  2. Select push
  3. Now select the Server you want to push to and the username/password fields should display.  Enter your credentials and click Push Deployment Plan.
  4. Magical wand...bells and whistles....everything should push to your destination server.
  5. Verify everything looks ok on the destination.
If you make updates to your book content, then a Push will get that to your live server.  This is awesome so that you can make changes, have it approved, and then push to your LIVE server.  Of course this approval process can be handled by workflow, but it's nice pushing and entire book (User Guide) at one time.  

Gotchas:
  • If you have images or other media in your book, they will not get pushed.  They need to be uploaded to the server.
  • Input Format: make sure the source and destination servers are setup with the same input formats.  This only needs to be done once of course.
  • After you have pushed, if you change the outline of your book and have added pages and messed around with it, it's possible to miss something.  You can still step through the book and add each page (even if it exists in your plan).  I have not found an issue with this yet.  NOTE TO SELF: It's best to remember to add the page to the deployment plan RIGHT AFTER you have created he page.

Monday, July 18, 2011

Better Formats - D6

For Drupal 6, here's another module that I will be adding to my standard Drush make file. Per the author "Most of the features in BF are in Drupal 7 core now." so that is sweet.

Better Formats | drupal.org

Tuesday, June 28, 2011

Git - weird log message

I was receiving messages in my git log with something like "Merge branch 'branchname' of /blah/blah into 'branchname'

Found this very helpful site and blurb on how to fix this.:
http://wiki.sourcemage.org/Git_Guide#Why_do_my_commit_emails_have_extra_.22Merge_branch_.27master.27.22_messages.3F

Basically, it talks about doing a rebase.

Friday, May 6, 2011

CKEditor in Drupal - Tip

Help your users and change one little configuration in the CKEditor Profile.  Taking the following steps will give them a more consistent interface between their editors (OpenOffice, Word, etc.)

  • Open the Profile in CKEditor that you are using
  • Goto "Cleanup and ouput"
  • Change "Enter mode" to <br>
  • Change "Shift + Enter mode" to <p>


Wednesday, March 23, 2011

Drupal and Drush - Problems on Fedora 14

Oh man!!!! what a pain in the @ss this was!
My problem: Using Drush to download Drupal and other modules, I continually received issues where it seemed like Drupal or the module wasn't there.  I would go to the site, and either the Drupal install wasn't recognized or the module wasn't recogized AT ALL.  I could install, update and even enable/disable modules with Drush, but they would never show up in the website.

SOLUTION:  not sure if this is with Fedora only or what (I'm on Fedora 14) but here is the command
chcon -Rt httpd_sys_content_t folder

folder, for example, might be the module you just downloaded.

It seems like Apache doesn't recognize or read the files unless the label is correct.  use "ls -Z" to see the labels.  This is something to do with SELinux.

Thanks to Madeye on this find (http://drupal.org/node/1044454).

Thursday, January 20, 2011

Drupal in NetBeans

Where to get it: http://drupalmodules.com/module/netbeans-templates

No this isn't a Drupal module, but where would something like this live otherwise? :) It's a collection of templates used within NetBeans and makes coding must faster. There are quite a few templates and it can take some time to figure them out, but the author did a good job using some naming conventions. For example, "h_menu" will insert a full template for hook_menu resulting in:

function mymodule_menu(){

  $items = array();

  $items['path'] = array(
      'title' => 'title',
      'description' => 'description',
      'page callback' => 'callback',
      'page arguments' => array('callback_arg'),
      'access arguments' => array('access_arg'),
      'file' => 'includes/mymodule_type.inc',
  ); 
 
  return $items;


}

After the template is inserted, mymodule is automatically selected and ready to be edited to the actual name of your module.

Installation instructions (as of NB 6.9):
  1. Rename nb_templates.zip.txt to nb_templates.zip
  2. In NetBeans, goto Tools > Options > Editor > Code Templates  and press the import button at the bottom.
  3. Browse and find nb_templates.zip, and select it.
  4. Select Editor > Code Templates
  5. Press OK

A must have for NetBeans users.

Friday, January 7, 2011

Module: AdminRole

Module Page: http://drupal.org/project/adminrole
Drupal Version Support:
  • 6.x -> YES
  • 7.x -> Included
From the module page:
This module is a little helper to maintain an administrator role which has all available permissions. By default, Drupal only has one super user and this module helps improve this drastically.

One of the first things many Drupal developers do when they create a new site is to create a role called "administrator" or something along those lines so that users other than User1 can do administrative tasks.  However, as soon as a new module or content type is added, you must go into permissions and enable the permissions for your custom admin role.   With the AdminRole module, you can select which role should be give these permissions by default.

HowTo:
  1. First make sure you create your administrator role.  "Admin" is just fine for a name and takes up a lot less space than "Administrator" on the permissions page.
  2. Once you've downloaded and enabled the module, goto User Management->User Settings and scroll to the bottom.  You should see something similar to this:
  3. Now just select the role you want to automatically assign new permissions to, and Save. 
This is one of the modules I include with every make file!!!.  And now it is included in D7, so sweet!