« February 2010 | Main | April 2010 »

March 25, 2010

Related content in Drupal

There are several modules out there that publish related content for the user to encourage exploration. Here are some notes:

A comparison of four approaches, see comments for more.

- Similar Entries

- Similar Content

- Similarity (appear abandoned)

- Featured content - a newish module

- Related Links - 6.x version is beta

- Similar Terms

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

March 18, 2010

Inserting images in Drupal Blogs

How to build the ability to insert photos into text bodies, quickly resize them and give the end-user the ability to see the full size image in a slick manner.

These steps are best used with these videos:

MustardSeed has a great video on the Insert module which covers one way to insert photos into blogs and other text bodies.

Lullabot has a good video (quality is so-so) on the Image Resize Filter.

1) Download (if necessary) and enable the following modules to /sites/all/modules:

- A third-party editor for WYSIWYG: FCKeditor or CKeditor
- CCK FileField
- ImageField
- Insert module
- Image Resize Filter Module
- Lightbox2
- Blog module

2) Setup WYSIWYG.
- Download and install fckeditor. Note, at first I tried ckeditor which is not compatible with image resizing.
$ sudo mkdir /blah/sites/all/libraries
$ sudo mkdir /blah/sites/all/libraries/fckeditor
$ sudo tar -xzf fckeditor_3.2.tar.gz
$ sudo cp -rf fckeditor/* /blah/sites/all/libraries/fckeditor/

- Go to admin/settings/wysiwyg and set CKeditor to be used in Filtered HTML settings. I didn't mess with the "Edit" section at all.

3) Configure Lightbox2 at admin/settings/lightbox2/
- I didn't change anything here

4) Setup HTML Input filter for Lightbox2 and Image Resize Filter (admin/settings/filters/)
- Edit: Check Lightbox2 and Image Resize Filter
- Configure: Add <img> to allowed tags; Check "Link to the Original" and add the word "lightbox" (no quotes) to 'rel attribute' box.

5) Create a directory for blog images.
$ sudo mkdir /blah/sites/default/files/images
$ sudo mkdir /blah/sites/default/files/images/blogs
$ sudo chmod 777 /blah/sites/default/files/images/blogs/

6) Add an Image field to the Blog content type (admin/content/node-type/blog/fields)
- field_blog_image; Type = File; Form element = Image
- File Path: images/blogs
- Enable Title Text; Default = "Complete this field for accessibility purposes"
- Enable Alt Text; Default = "Complete this field for search engine purposes"
- Enable Insert button

- In the Display settings, set the image field to hidden. This means the image will only appear when inserted into text.

7) Create a post, upload an image and resize it. If it is resized from the original, when you click on the image Lightbox should pop up and takeover.

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

More on Images in Drupal

One of my goals with the alpha site is to get Bob up and running on a blog. In order to do this, I need to figure out how to handle the images. Here are notes:

MustardSeed has a great video on the Insert module which covers one way to insert photos into blogs and other text bodies.

Lullabot has a good video (quality is so-so) on the Image Resize Filter.

These are the recommended modules:
- WYSIWYG - I currently have this installed on the original demosite. You also need to download a third-party editor. From what I can tell, FCKeditor is a good way to go. The newest version is now named CKeditor, apparently.

- CCK and CCK FileField (a CCK sub-module)

- ImageField allows you to create an image field type for custom content types.

- They say ImageField pairs very well with ImageCache. A closer look at imageCache indicates a lot of dependencies (i.e., baggage) which is exactly what I'm trying to avoid at this point...

- The Insert module "makes inserting images and links to files into text areas or WYSIWYGs much easier."

- The Image Resize Filter Module allows the user to easily resize images in a text body. When the content is posted the resized image is the only image available (e.g., right-click, view image will show the same size image. People are apparently enthused about this but I'm not fully sure why.)

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

Google Analytics on Drupal

We'll probably want to do this at some point. Here's a good video introduction:


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

March 11, 2010

Load latitude and longitude into Drupal via database

Here are my notes:

1) Paired the research and their NIDs with the Lat/long data from bob.

2) Loaded this information into the location table. (reference file: insert_into_location.sql). Note, before loading the lats/longs I changed those database field settings from Decimal(10,6) to Decimal(14,10) to avoid the truncation of the coordinates I input.

INSERT INTO `database`.`location` (
`name` ,
`country` ,
`latitude` ,
`longitude` ,
`source` ,

'Sucker River' , 'us' , '46.665334' , '-85.890727' , '1' , '0'),
( 'Lake Erie' , 'us' , '41.846071885' , '-83.2438109141' , '1' , '0'),
( 'Lake St. Clair' , 'us' , '42.4906916199' , '-82.7712197327' , '1' , '0'

3) Following this site I created a temporary table and loaded the matched nid's and lid's.

(reference file: insert_into_tempTable.sql)
INSERT INTO database.tempTable(

nid, lid


'7958' , '4945' ) ,
('8003' , '5105' ) ,
('7899' , '5112' ) ;

I then transferred this data over to the proper table:
(reference file: update_researchSite_lids.sql)
UPDATE database.content_type_research_site , database.tempTable
SET content_type_research_site.field_research_location_lid = tempTable.lid
WHERE content_type_research_site.nid = tempTable.nid

4) After step 3, all of the sites mapped properly.

5) I also noticed that the LID's showed up in one additional table. I don't know what this table does, but I felt it prudent to insert the relevant information into that table as well. (reference file: insert_into_location_instance.sql)

INSERT INTO database.location_instance (
nid, vid, uid, genid, lid

'0' , '0' , '0' , 'cck:field_research_location:7958' , '4945' ) ,
('0' , '0' , '0' , 'cck:field_research_location:8003' , '5105' ) ,
('0' , '0' , '0' , 'cck:field_research_location:7899' , '5112' ) ,

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

March 08, 2010

Digitizing biological collections

I received an email from our Resident Biologist, Bob Vande Kopple, pointing me to this website.

This spurred me to hash out a quick plan for digitizing our biological collections. I posted it at the above site as a comment but am reposting it here for posterity's sake:

Great timing. Our biological station has a small collection (~20,000 floral and faunal specimens) which we are just beginning to digitize. Given staffing constraints and variable confidence in taxonomic identifications we are using the following, low-overhead approach.

We are beginning with our largest and highest quality collections - vascular plants and bryophytes. We are collaborating with a larger institution (the University of Michigan Herbarium) from which we are receiving a database schema, hardware and software recommendations, and training for the digitization and QA/QC process.

In exchange, the UM Herbarium will receive unique specimen records and more precise location information for known collection sites in our region. Once this phase is complete, we will be better able to tackle our smaller and more complicated collections. We will also use this time improve the quality of the identifications in those collections.

My thoughts for the project outlined on this website are as follows:

For the digitization process, I believe a regional (i.e., dispersed) effort that pairs complementary institutions is best. A mentor-mentee relationship, if you will.

However, how to get our collection online, integrated with multi-institutional databases and how to leverage these databases is an outstanding question. For this phase of the project I think the ability to consult with technical experts located at a centralized institute would be best. I think this is the phase where uniformity should be enforced. I could foresee help in mapping our database schema to whichever data standard is adopted as well as how to best serve up and leverage data from an IT perspective.

Kyle Kwaiser, Information Manager
University of Michigan Biological Station

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

March 05, 2010

Create biblio to research site node references

1) Query for biblio NIDs and associated research sites.

SELECT nid, biblio_custom3
FROM `alpha_biblio`
WHERE biblio_custom3 IS NOT NULL

2) Query for research site NIDs and names:

SELECT nid, title
FROM `alpha_node`
WHERE `type` LIKE 'research_site'

Currently going back to the bib and fixing names. problem with (), don't know why.

3) I used a python script to match the biblio NIDs and the research site NIDs based upon the name. In the process, I found and corrected a number of errors. It would have been more efficient to build the sql into the pyton script but I didn't want to take the time to figure that out.

#! /usr/bin/python
# execfile("/blah/scripts/combineNIDS.py")
import sys, tempfile, string, re, csv, os
fi1 = csv.reader( open('blah/biblioNID_withResearchSites.csv', 'r') , delimiter=',', quotechar='"') #biblio NIDs
fi2 = csv.reader( open('blah/researchSites_with_NID.csv', 'r'), delimiter=',', quotechar='"') # research site NIDs
fo = csv.writer( open('blah/io/matchedNIDs.csv', 'w')) # output Document
bibNID = list()
pairedNID = [["bibNID", "siteName", "siteNID"]]
siteList = list()
pairedNIDCounter= 0

# this loop pairs each research site with the NID of the respective bibliography entry
for row in fi1: #each row is a bib entry
a = row[1].split('/') #separate research sites for a given bib entry
for site in a:
bibNID.append([ row[0], site.strip() ]) # this list is each site in the bib with the biblio NID
for row in fi2: # create a reserach site list we can work with

for bibSite in bibNID: # grab a site from a publication
pairedNIDCounterBeforeTest = pairedNIDCounter # see below
for aSite in siteList: # grab a research site
#print aSite
if bibSite[1].strip() == aSite[1].strip(): # do the two sites match
pairedNID.append([bibSite[0] , aSite[1] , aSite[0]])
pairedNIDCounter += 1
#print pairedNIDCounter
if pairedNIDCounter == pairedNIDCounterBeforeTest: # if this test is TRUE, then a site from the biblio did not have a matching research which means something is wrong
print bibSite #print the biblio site that doesn't match a research site
fo.writerows(pairedNID) # this is the matched NIDs

except IOError:
print 'Can\'t open file for reading.'

4) I then used the following sql files to load the data into the database:

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

March 02, 2010

Goin' to Brazil

Here's what would need to happen in order for me to attend GLEON 10 in Torres, Brazil on May 10-14th, 2010. And here's where Torres, Brasil is:

View Larger Map

1) Looks like I need to buy my ticket first
2) Then complete the GLEON application: http://www.gleon.org/forms/GLEON_10_registration.php
3) The use the paper work from 1 and 2, along with passport, photo etc to apply for my visa. Apply for a visa here.

4) More info on the tourist visa is here.

5) This page explains how to mail the visa application. Need to use USPS Express, include an Express return envelope, $150 money order for the visa fee.

Mail the Visa application to this address:

Consulate General of Brazil in Chicago
401 North Michigan Avenue, suite 1850 - Chicago, IL 60611

From this page, it looks like I need a tourist Visa.

1) Tourist Visa ( VITUR ):

* Tourism trip;
* visit to relatives and/or friends;
* scientists, professors or researchers attending cultural, technological or scientific conferences, seminars (unpaid speakers).
* participation in artistic or amateur sport competitions, whenever no monetary prize or paid admission is involved.

Tourist visa holders are not allowed to engage in any paid activity in Brazil.

This page explains how to mail the visa application. Need to use USPS Express, include an Express return envelope, $150 money order for the visa fee.

Mail the Visa application to this address:

Consulate General of Brazil in Chicago
401 North Michigan Avenue, suite 1850 - Chicago, IL 60611

- Here's a link to the Dept of State website:

- Looks like flights start at $1000 and takes a minimum of 18 hours of travel.

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

Multiple search boxes

I finally figured out how to do this:

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

Google maps notes

Here are notes on creating a block view of a gmap that shows only the research site being viewed. It uses the same view used to create the research site map I outlined a while ago.


1) Edit the view
2) add a block view
3) Add an argument:
Provide default argument > Node ID from URL
Action to take if argument does not validate: Display all values
- The last step is important because it allows all of the sites to show up when you go to view the main map. Otherwise the node NID argument for the Map view fails and nothing appears

4) The last step will be to add a bit of php to the administer > blocks > research site section. This will mimic the biblio block I created earlier and will ensure that the map only shows up when someone is viewing a research site.

Other notes. These sites look cool:

Something about Views inheriting arguments, didn't follow up on this but it may be useful in the future: http://drupal.org/node/349739

Tutorial on customizing gmaps, nice links to live websites that showcase legend and staggered loading of markers, code included: http://www.anelloconsulting.com/custom_gmap_solution_dynamically_updated_markers_part_2

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

March 01, 2010

Theme the alpha site


text-shadow:0 1px 3px #4A633D

Change the color to match the following to get the links to show up properly:

Line 566:

ul.primary-links li a:hover, ul.primary-links li a.active {
color: #4a633D;
background: transparent url(bg-navigation-item-hover.png) no-repeat 50% 0;

Line 558:

ul.primary-links li a, ul.primary-links li a:link, ul.primary-links li a:visited {
display: block;
margin: 0 1em;
padding: .75em 0 0;
color: #4a633D;
background: transparent url(bg-navigation-item.png) no-repeat 50% 0;

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