Showing posts with label how-to. Show all posts
Showing posts with label how-to. Show all posts

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!!!! :)

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

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.

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>


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!