HOWTO #1: Retrieving the first line of a CSV file

Alright, so let's start with a simple example. For this tutorial (and other subsequent CSV import/export HOWTOs), we'll use an example CSV file called courses.csv. Assuming it has been exported from Microsoft Excel, it might also contain semicolons instead of regular commas. Here's the contents; just paste it into your favorite text editor (I know you love Kate) and save it as a new file:

Course Name;Instructor;Units;Unit length (hours);Max number of attendants
Taekwondo;George Wright;12;1.0;20
Aikido;Lukas Gangoly;24;1.5;30
Hands-on pressure point demonstration;Christian Budai;1;0.5;3

In the second CSV HOWTO, we'll import the data rows into Drupal nodes. For that, we will need a list of field names so that the CSV fields can be properly mapped to node/CCK fields. Therefore, this first tutorial shows how to extract the first line of the file as a list of text items (strings) that other operations can use. This first one won't write any data yet, so don't worry about breaking your Drupal. Mind that for the CSV operations used in here, you need the CSV Transformations extension module installed in addition to Transformations' core modules (API and UI).

Creating the pipeline

Installation

Transformations API has no dependencies, but won't do anything for you unless you also get a user interface that makes use of it.

In order to enable Transformations UI, you need Earl Miles' Chaos tool suite installed.

Term Display theming

Theming terms

Both the List and Custom display options use theme functions, theme_term_display_list and theme_term_display_custom respectively.

The Load display option places data into the $node object, from which your theme can retrieve it, format it, and place it anywhere in the node template.

The format is as follows:

    [term_display] => Array
        (
            [7] => Array // the vocabulary ID
                (
                    [vocabulary_name] =>  // the vocabulary name, run through a check_plain
                    [terms] => Array   // an array of terms, in the same format as the $node->taxonomy array.
                )

The array of terms is an array of objects, each keyed by its term id (tid):

   [taxonomy] => Array
        (
            [56] => stdClass Object
                (
                    [tid] => 56
                    [vid] => 2
                    [name] => NAME
                    [description] => 
                    [weight] => 0
                )

See below for examples of what can be done with this.

Theming examples

The following examples of code should go in your theme's template.php, in either _phptemplate_variables()'s node case (Drupal 5) or theme_preprocess_node (Drupal 6). These will add an extra variable to be used in your node.tpl file.

Beginners option | "Got a packet bigger than 'max_allowed_packet' " error

The following is the beginners option. This should work on most share hosting.

When using Drupal your browser returns the following error

Got a packet bigger than 'max_allowed_packet'

The most likely cause of this error is your MySQL server. If you're new to Drupal think of MySQL server as a database.

Steps to fix this
Install the 'drupal_tweaks' module http://drupal.org/project/drupal_tweaks

Advanced option | "Got a packet bigger than 'max_allowed_packet' " error

The following is the advanced option. You need full root access to your server. This will not work on most share hosting.

When using Drupal your browser returns the following error

Got a packet bigger than 'max_allowed_packet'

The most likely cause of this error is your MySQL server. If your new to Drupal think of MySQL server as a database.

Here are the steps to fix this on Ubuntu 8.04.x LTS desktop edition:

Mail Comment Documentation: How to install Mail Comment

On this page

  1. Installing Drupal
  2. Enabling the required modules
  3. Configuring the Mailhandler module
  4. Testing the Mailhandler module
  5. Setting up messaging
  6. Setting up notifications
  7. Configuring the Mail Comment module
  8. Creating a forum
  9. Testing the Mail Comment module with the forum
  10. Altering message templates
  11. Configuring cron to run automatically
  12. Caveats and issues with this tutorial

These instructions explain the process of installing and configuring Mail Comment to create online forums that allow full inbound and outbound email participation. Participants receive copies of new forum posts by email, and if they reply to the emails, the replies are posted to the forum. The result is a forum that doubles as a Listserv.

Installing Drupal

Pages

Subscribe with RSS Subscribe to RSS - Site administrators