« August 2010 | Main | October 2010 »

September 28, 2010

Importing Contents Types in Drupal


1) Go to the training site and login.

2) Go to the Content Type Import page (Administer > Content Management > Content Types > Import)

3) Open the DEIMS* content type repository in a new browser tab

4) Select a content type and copy only the PHP code

5) Return to the drupal training site and paste code into the import box

6) Click Import

7) View the content type settings and fields by clicking on Edit and Manage Fields

8) Wash and repeat as needed

*Drupal Ecological Information Management System

Posted by kkwaiser at 03:55 PM | Comments (0)

September 23, 2010

Taxonomy helper modules

These modules deal with expanding the core taxonomy module. I'm considering adding a vocabulary that is a species taxonomy which could be used 1) for tagging Projects, Publications and Datasets and 2) as part of our species presence/absence lists.

Such a taxonomy would be very large when considering the number of species that have been identified for UMBS and the immediate region.

Redundancy of names. A species same (e.g. canadensis) can be reused any number of times meaning selecting a species-level term from a vocabulary could become neigh kim-possible. It is worth noting that genus names are NOT repeated within a kingdom.

The shear number of terms in this vocabulary necessitates an autocomplete or hierarchical selection capability (see Modules, below). By default, the taxonomy allows doesn't have an autocomplete function without free-tagging. The only way to allow someone to select a term without giving them the ability to add new terms is through a select list - which would be too long - or through a 3rd party module.


Taxonomy Lineage "module adds a table to the taxonomy database which allows nodes to be sorted by taxonomy hierarchy."

Hierarchical Select allows the user to narrow down the vocabulary term they want by narrowing down the list of choices. No autocomplete.

Hierarchical Select Field Selector
somehow extends the HS module.

Content Taxonomy - allows the a cck field to reference a vocabulary (rather than putting a taxonomy field into the content type as a node field.) Additional claimed capabilities suggest that this module should be a starting point for experimentation. Upgrade path to D7 not set yet.

Unitag Module "Make a free-tagging vocabulary read-only. Non-existent terms are not included and are instead sent to a management interface where they can be dealt with appropriately." Other features too.

Taxonomy Single Tag - limit free tagging to one term.

Big Autocomplete Taxonomy - Triggers an autocomplete option if a vocabulary exceeds a prescribed number of terms. From the EDIT people.

Posted by kkwaiser at 10:18 AM | Comments (0)

September 20, 2010

Potential Registration solution

Going to skip the intro for now.

Interesting resources and modules:

Content Profile Module allows you to associate one or many custom content types with a registered user. For example, the Person content type (which hold the name, address, institution reference) could be linked to a User. There is the ability to make the content type part of the User registration process. Multiple content types can be part of the content profile, meaning a Research Project could be part of the registration process as well. Very. Cool. Module.

- How does the content profile module work? That answer is the in this comment (like it was a secret that someone mistakenly let slip.)
- A sketch of an approach for having different registration processes for different roles.
- Interesting issue with good module suggestions: My user flow: choose role, register with partial profile, complete profile
- This post explains how a single user can create multiple content-profile-related content types without getting the error "User already has associated profile." Basically, you set the Author to Anonymous.

Auto Assign Module "provide[s] an automatic assignment of roles when a new account is created.... [It] allow[s] the end user the option of choosing their own role or roles when they create their account and provide[s] paths that will trigger a specific role when an account is created."

- My use case with this module may allow Users to select their role at UMBS (e.g., Teaching Faculty, Graduate Student, PI, etc.) which would then (purportedly) shuttle through a different registration process. See the "My user flow..." link above for more.

- Looking more at this module, it does seem that AutoAssignRole allows two different roles to have different content types associated with them through its integration with Content Profile. For example, both the Instructor and Researcher roles would associate with the Person content type but only researcher would have the Research Project content type associated with it. Multiple registrations forms seems possible with AAR + CP.

Profile Role Module appears to be redundant with AAR (above) but I haven't look into it much.

Automatic Nodetitles is a helper module that would remove the node title field from the registration form.

Email Registration Module - Users can register with an email, no username necessary meaning the username can be removed from the form.

Rules Module for automating processes; good discussion here.

Login Toboggan Module offers several extensions to the login system.

Workflow Module - don't know anything about it, just a bookmark.

Unvetted but interesting modules

User Import


Posted by kkwaiser at 04:43 PM | Comments (0)

September 17, 2010

GMap with KML overlays in Drupal

I've started messing around with the idea of converting our spatial data to KML files to allow us to display on the website. Here are some notes:

Modules Needed:
GMap Addons

To add the same overlay to every node of a given content type:

1) Create your custom content type (call it cct)
2) Add a Location field to the CCT (call it cct_location)
3) Edit the settings of cct_location (admin/content/node-type/cct/fields/field_cct_location)
- Add your macro in the GMap Macro section. My test case uses this code:

[gmap |overlay=kml:http://www.ancientforestnationalpark.org/AncientForestParkGoogleEarth.kml | zoom=3 |center=40.49709237269567,-121.7724609375 |width=100% |height=800px |control=Large |type=Physical]
4) Make sure your CCT is set to display GMaps when viewing the Full Node (admin/content/node-type/cct/display)
5) Now Create Content > cct and add a location. Be sure to put to put in a Location Name (and lat/long or address.)
6) View your node.

Add an overlay to a particular node of a given content type:

1) Create your custom content type (call it cct)
2) Create a GMap Macro Filter for the Body text box. I swiped the following from here.

Go to your input formats config page at admin/settings/filters
Click 'configure' next to the input format that will be used for the content where the map is to be included (typically filtered HTML)
Check 'GMap filter' and save

Now when you insert a gmap macro into a page it should automatically turn into the map with your marker.

3) Create Content > cct
4) Past your macro into the text body. Under Input Format, select GMap Macro. My test case uses this code:
[gmap |overlay=kml:http://www.ancientforestnationalpark.org/AncientForestParkGoogleEarth.kml | zoom=3 |center=40.49709237269567,-121.7724609375 |width=100% |height=800px |control=Large |type=Physical]
5) View your map.

Note: This should also work if you add a cck text field

Add an overlay to a View:

1. Add Node View
2. Add Page Display
3. Set Path
4. Change Style to GMap
5. Change settings for GMap style. Add a macro (or two):
[gmap |overlay=kml:http://gcrc.uga.edu/public/uploads/GCE_site_boundaries_20090724T114716.kml]
[gmap |overlay=kml:http://www.ancientforestnationalpark.org/AncientForestParkGoogleEarth.kml]
Note: I found these kml files on the web by googling "polygon filetype:kml"

6. At this point, you will need to add fields (a requirement of Views). I followed this tutorial the first time I experimented with Gmap + Views. If this part confuses you, you've got a ways to go.
7. Save and navigate to the Path URL.

- If you get an annoying popup window that says only "gmap-auto1map-gmap0" this issue may help #341589: Browser error on overlay

Posted by kkwaiser at 03:27 PM | Comments (0)

September 16, 2010

Customizing User Registration page

A few resources:

Good tutorials:

Content Profile related issues:

Crappy tutorial (D4 and 5 only, GRRRR!):

Posted by kkwaiser at 04:30 PM | Comments (0)

Setting default values for CCK values based upon Content Profile fields

One nice thing about Content Profile is, if you've marked a content type as part of the profile and set it as part of the user registration process, once a person registers, you can easily bring that data into cck fields as the default value. Here, I created a text field (name) in a content type and placed this code into the default value field at admin/content/node-type/[your content type]/fields/field_name

global $user;
$default = content_profile_load('person', $user->uid);
  if (!empty($default->field_person_first_name) || !empty($default-> field_person_last_name)) {
    $fullname = $default->field_person_first_name[0]['value'] . " " . $default->field_person_last_name[0]['value'];
    return array(
        0 => array('value' => $fullname)
else return array();

If this makes sense...my thought right now is that once a person registers, they would be redirected to a new page (based upon their role) that allows them to apply for housing and or complete the research portion of the project. These forms (the housing form in particular) could be pre-populated with the code above. This is important because a single person will often submit several housing application forms in a given year.

I'm not sure yet how to deal with research projects though. It cannot really be part of the profile because multiple people will share the same project and not everyone has a project. That said, the creation of a research project needs to be mandatory for certain people (e.g., Investigators) so how can that be enforced (programmatically)?

This is probably a good time to reference this blog post: Building forms with cck, actions and workflow

Posted by kkwaiser at 01:17 PM | Comments (0)

September 14, 2010

Differences between $Drush cron and web cron

Oh man, I just learned that clearing your cache and running cron via the web interface vs drush's command line are two different beasts. In the latter case, cron goes into files that the web cron doesn't touch.

This caused problems for me because I hadn't set the base URL and I operate in a subdirectory (e.g., www.example.com/subdir is my homepage.) The problem arose around my gmap pages; the full story is here.

I suppose the moral is to set your Base URL in settings.php if you're working out of a subdirectory.

Posted by kkwaiser at 02:35 PM | Comments (0)

September 13, 2010

Referencing Views from Nodes

I'm interested in finding a functionality similar to the CCK Node Reference module that can point to Views. Here are some options/resources:

View Reference Module adds a CCK Field that will autocomplete with the list of views. Haven't tried it but I'm optimistic.

View Field module - have tried it out and it does work but something about it had left me wanting more.

This issues compares ViewField to NodeReference (from NR perspective.) Nice list of similar modules too.

Both viewfield and viewreference have a solid usage community but they seem to take fundamentally different approaches. I need to learn a bit more about the pro's/con's of those approaches.

Right name, wrong functionality:

Views Attach "will show all nodes that nodereference TO the node currently displaying (plus whatever other filters you have)."

Node reference views "is fundamentally different from modules such as Viewfield, View Reference. These give you a field where you pick a different view for each node. Contrast with this module, where the same view is shown on all nodes: what differs is the list of nodes within the view, which are those you picked in the CCK node reference field."

Not a chance:

Insert View module: Any module that greets you with a security disclaimer is a non-starter for me.

Posted by kkwaiser at 01:33 PM | Comments (0)

Interesting menus modules

Just noting these for future reference:

DHTML Menu Module - reduce pageloads if using drupal's stock menu system.

Menu Block Module - need to look at it more but it appears a to supplement the cord menu system fairly well

Posted by kkwaiser at 01:28 PM | Comments (0)

September 10, 2010

Post-Installation Notes on using Drush

First things first:
- Change to the root of drupal install before running Drush commands (there may be a way around this, likely involving Alias(?))

Within Drush FAQs
$ drush help

Run Cron:
$ drush cron -v

View available updates:
Navigate to admin/reports/updates
$ drush up (then press n to abort)

Update a module:
$ sudo drush up webform

Note: some modules appear to have spaces in the name (e.g, jQuery UI), use sm to find the actual module name:

$ drush sm
$ sudo drush up jquery_ui

Update database:
$ sudo drush updatedb

Posted by kkwaiser at 10:13 AM | Comments (0)

How To Install Drush

Here are my notes on getting drush installed on my dev machine:

1) Get installation directions (inside README.txt) by going to the Drush FAQ. Read instructions.

2) Download the latest version of Drush from the project page.
$ sudo wget http://download.pear.php.net/package/Console_Table-1.1.3.tgz

3) Unpack the tar.gz into your desired directory. I put it in /opt (not sure if that is recommended practice though.)

$ cd /opt/
$ sudo mv drush-6.x-3.3.tar.gz /opt/
$ sudo tar -xzf drush-6.x-3.3.tar.gz

4) Make the drush command executable
$ sudo chmod u+x /opt/drush/drush
$ sudo ln -s /opt/drush/drush /bin/drush

5) Check if drush is working
$ drush help

I got this error at first:
exec: 53: php: not found

The fix, for me, was buried in this tutorial:

If you get an "exec: 53: php: not found" error after running the last line ("sudo drush dl drush_make") you might have to install the PHP command line interface, with

sudo apt-get install php5-cli

From: http://groups.drupal.org/node/70268

6) Check if drush is working, again:
$ drush help

New (but helpful!) error:

PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0
Drush needs a copy of the PEAR Console_Table library in order to [error]
function, and the attempt to download this file automatically failed
because you do not have permission to write files in
/opt/drush/includes. To continue you will need to download the 1.1.3
package from http://pear.php.net/package/Console_Table, extract it,
and copy the Table.php file into Drush's directory as
Drush could not execute.

6) Do what the Error Message tells you to do:
- Download the PEAR Console_Table library

$ sudo wget http://download.pear.php.net/package/Console_Table-1.1.3.tgz
$ sudo tar -xzf Console_Table-1.1.3.tgz
$ sudo mv Console_Table-1.1.3/Table.php /opt/drush/includes/table.inc

7) Check if drush is working, yet again:
$ drush help

8) Success, next step is to learn drush commands.

Posted by kkwaiser at 09:38 AM | Comments (0)

September 09, 2010

Summary of mapping modules in Drupal

First off, here is how I'm currently mapping in Drupal:


GMap Module
Location Module
Plus: CCK, Views, CTools, Panels

The Location module supplies the ability to associate locations with nodes in (at least) two ways: 1) Node Location (similar to a Node Title) and 2) CCK Location Field. I use the CCK Location Field. Location also offers Views integration.

The GMap module (maintained by the same team as Location) adds Google Map interface capabilities to the Location and Views module.

I use GMap and Location to georeference nodes of the Institution and Research Site content types. Examples are here:

A View of the sites comprising our research site gazetteer. Note, I am using Jef Poskanzer's Clusterer to group sites.

Here is an example of a research site. The GMap shown is a View modified from that listed above. Basically, I added an NID argument (taken from the URL) to show only the given research site and a tiny GMap macro that autozooms and resizes the map.

I also associate an Institution with nodes of the Person content type and map them here. This is less functional, but it is cool to see where our visitors (researchers, faculty, students, others) come from.


Additional Modules

GMap Addons Module - allows overlay support for KML and other layers. Also, more baselayers. Same maintainer as GMap and Location (bdragon.)

Mapstraction Module - Integrates with Location and Geo Modules to allow the user to select any of a number of mapping services. Low usage numbers. Documentation here.

Geo Module - similar to Location but with support for lines and polygons. Perhaps more advanced in terms of loyalty to GIS principals?

Notes: there's an uncommitted patch for GMap to support polygons.

Geocode and Postal Modules have same maintainer as Geo Module (Allie Micka) and seem designed to extend that module.

OpenLayers Module - the non-proprietary version of the GMap Module? Seems to standalone (don't need Geo or Location.) In fact, integration with Location may not work. This video indicates that OpenLayers is more powerful but harder to use than Gmap. Can create polygons and lines via point and click map interface.

Posted by kkwaiser at 09:42 AM | Comments (0)

Images directly into an access database

The proposed workflow for the digitization of our vascular plants collection currently looks like this:

1) Volunteer takes photos of specimen label
2) Volunteer places barcode onto specimen sheet
3) Put both barcode and photo into same row of database
4) Send database to UM herbarium, where they will sync the labels/barcodes with the records they have already digitized.


Is there a way to get the photos to feed directly into a database field? The barcode scanner can feed directly in. This plan falls apart if the image (or a pointer to) is not automagically inserted into the database.


This article explains how to store images in the database, link to the images, and use VB to display the images.

This old post (Access 2000?) claims you can feed an image from a webcam directly into an OLE field. Doesn't appear to translate directly to Access 2007.

The comment from Razorking in this post indicates that it is simple to feed barcodes into databases, why not photos?

Another post, not sure how useful it is. Talks about feeding webcam images into access.

Some VB code examples here and here.

Posted by kkwaiser at 08:57 AM | Comments (0)

September 07, 2010

Install Eclipse on Ubuntu 10.4

Here are my notes on installing Eclipse

Mostly followed this page.

Downloaded Eclipse here, note I took the Classic 3.6.0 for 32 bit Linux

Installed the PHPEclipse package following this page. I used this as the source link.

Posted by kkwaiser at 03:33 PM | Comments (0)

September 01, 2010

Revisiting the Taxonomy XML module

I decided to try out the Taxonomy XML module's web service support again. Made a bit more progress this time but am not convinced this is a better solution than building my own species taxonomic vocabulary in Drupal.

Here are the notes:

1) Installed the latest dev version of Taxonomy XML (6.x-2.x-dev).

2) Enabled the Taxonomy GUID and Taxonomy Import/Export via XML

3) Import a taxonomy
- Browse to admin/content/taxonomy/import
- Target Vocabulary: Create New
- Data Source: Web Service
- Taxonomy Server: Biodiversity ... LSID Web Resolver
- Unique Identifier for this service: urn:lsid:ubio.org:namebank:11815
Note: Example LSID taken from the LSID Web Resolver website.
- Optionally enable the "Recurse down the taxonomy tree"
- Import

4) Checking out new taxonomy

A taxonomy is actually created
It doesn't appear to read the schema correctly as the names are almost all incorrect (the LSID is used in place of the actual name.)
Descriptions don't seem to appear either.
Hierarchy seems to import correctly.
Recursion option seems to work

Final point worth mentioning is that there doesn't seem to be a search function (within the LSID resolver) meaning you need to know the full LSID before you can import.

Posted by kkwaiser at 11:43 AM | Comments (0)

Overall Approach to Data in Tables with Drupal

This should be considered a first pass as the verdict is definitely still out.

I've spent the last couple of days figuring out how to store datasets in tables with Drupal in a manner that is (somewhat) consistent with my overall approach.

Here is an example page that accomplishes this with mock-data:


Here are the key modules I'm using:

Data module - to manage the tables and expose them to Views.
Views - obviously
CCK - obviously
Schema - Data module dependency
CTools - Data Module dependency
Feeds - Recommended by Data module for creating tables and importing data which are then managed via the Data module
Views Bonus Pack - allows CSV/XLS export of views
ViewField - Create a CCK ViewField that embeds a specified view into a node
Panels - for the arrangement

The workflow for this is roughly as follows:
1. Create table/import data
2. Add CSV/XLS feeds to data table view
3. Add data table view to the appropriate DataSet node.

I'm not completely happy with this approach because I use the ViewField module to essentially relate a Data Table View to a Node (i.e., DataSet) whereas I feel the Data module should be able to accomplish this itself. The Data module does have a Relate to Node function but I haven't figured out how to leverage this and the module documentation is atrocious. Overall, the Data module appears immature but promising.

Posted by kkwaiser at 10:15 AM | Comments (0)