July 11, 2008

Install Drupal Modules via CVS

Filed under: Drupal — Soleer @ 8:26 am

CVS deployment enables a whole new level of simple installation and upgrading.  To install a Drupal module using the standard method, you have to:

  1. Find the module on Drupal.org
  2. Wait for the Module to Upload
  3. Unzip the contents
  4. Connect to your FTP server
  5. Browse to the module directory
  6. Wait for the module to upload

Using CVS installation, all you have to do is:

  1. Enter one command into your ssh program. (The files are downloaded and installed directly from server to server in lightning-fast fashion)

Even more impressive, is the fact that if you install the module using CVS, you can also upgrade using a very short command in your ssh program.

Now that your excitement is palpable, let’s get into the how.  Here are the prerequisites:

  • SSH/Shell access to your server.
  • Some sort of SSH client.  (I use putty on windows)
  • Hopefully some understanding of unix commands

Now that you have all of the necessary tools, let’s install a module! 

  1. Use your SSH client to connect to your server
  2. In your client, navigate to your modules directory
  3. Browse to: http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/ (This is the CVS repository for modules)
  4. Click on the link for your desired module (We’ll use the pathauto module for our example)
    CVS Drupal Module Repository
  5. Go the the Sticky Tag Selection, and make note of the latest stable version of the module for your drupal release.  In this example, I’m running Drupal 6.x.  So, the latest release for pathauto at the time of this writing is “DRUPAL-6–1-1″.  Take note of this; we’ll call this {latest_stable_version}.  Also note how the module is listed in the directory structure at the top of this page (contributions/modules/pathauto), in this case, the name is listed as “pathauto”.  Take note of this; we’ll call this {module_name}.
  6. Type the following command:

    cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -r {latest_stable_version} -d {module_name} contributions/modules/{module_name}

    So, for our example, the code would look like this:

    cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -r DRUPAL-6–1-1 -d pathauto contributions/modules/pathauto

  7. Voila!  It’s installed.  All you have to do is enable it in your drupal admin section.

Stay tuned for a post on how to update via CVS…

March 24, 2008

How to Display CiviCRM events on a Drupal Calendar:

Filed under: CiviCRM, Drupal — Soleer @ 9:52 am

How to Display CiviCRM events on a Drupal Calendar using CiviEvent’s iCal Feed and the Drupal Calendar Module:

  1. Pre-requisits: You’ll need an instance of CiviCRM running on Drupal, (we’re using Drupal 5.5 with CiviCRM 1.9) with CiviEvents Enabled.
  2. Download & Install the following Drupal modules:
    1. Calendar: http://drupal.org/project/calendar
    2. Views (required by Calendar): http://drupal.org/project/views
    3. Date (required by Calendar): http://drupal.org/project/date
  3. Go to your Module management screen ( Administer >> Site Building >> Modules )
    Screenshot 1

    1. Enable Calendar View
    2. Enable Calendar iCal
    3. Enable all other modules required by these
  4. Go to the “Administer Views” screen ( Administer >> Site Building >> Views)
    Screen shot 2

    1. Set ‘calender’ view status to ‘enabled’
    2. Click on the ‘add’ link next to calendar
    3. Screen Shot 3

    4. On the “Add a View” Screen, under Access, select all the roles you want to be able to view this calendar.
    5. Go to the bottom of the page and click save
    6. You will now see ‘calendar’ listed under ‘existing views’
    7. Click on the ‘calendar’ link listed in that same row or go to the calendar url, which should be http://www.yoursite.com/calendar (if you have drupal installed in the base directory) or http://www.yoursite.com/drupal/calendar (if you have drupal in it’s own directory).
  5. Go to your “Access Control” page. (Administer >> User Management >> Access Control)
    1. Under CiviCRM, make sure “register for events” is enabled for your anonymous role, and any other roles you are going to want to register for events.
  6. From the Calendar page, you should see the following:
    Screen Shot 4

    1. Click on the “iCal” tab, and insert the following information:
    2. Screen Shot 5

    3. Under “Expire iCal cache:” I recommend setting this to ‘0 sec’ for debugging purposes, and then scale back based on your traffic and update timing requirements.
    4. Set the Name as anything, I went with “civi” to keep it simple.
    5. Set the Url to your civi iCal feed.  Should be something like:  http://www.yoursite.com/civicrm/event/ical?reset=1&page=1  or http://www.yoursite.com/drupal/civicrm/event/ical?reset=1&page=1 .
  7. And that should be it!  Set up a test event, and make sure it shows up on your calendar page.

February 19, 2008

Disabling Drupal Modules via your Database

Filed under: Drupal, MySQL — Soleer @ 6:41 pm

Due to the occasional small (or large) fluke, your entire Drupal website can become inaccessible because of a module.  This is how you solve the problem: disable the specific module by altering values in your Drupal database.

In our case, we’ll use phpMyAdmin, but you can use whatever utility you prefer for database manipulation.  So, here is what you do:

  1. Login to your Drupal Database
  2. Access the ’system’ table.  If you added a table prefix: <prefix>, the table will be listed as ‘<prefix>system’
  3. Browse the table entries, and find the entry for the target module
  4. Edit the table entry, and change the status from ‘1′ to ‘0′
  5. The module is now disabled!

Hopefully that did the trick, and you can now use your website.

January 7, 2008

Control Drupal Forum Access by Role

Filed under: Drupal, PHP — Soleer @ 9:56 pm

We are developing an online community with forums which need to be private (only accessed by the members of the community).  Unfortunately, the forum.module for drupal allows anyone with ‘access content’ privileges to access the forums.  Obviously, we want visitors to be able to view the pages and almost all other content, but we want the forums to be private. 

There is a module called Forum Access, which enables great control over forum access, but if used to disable access for visitors and other roles, these users will still see a Forum menu item, and if they click on it they will see a “No Forums Defined” message.  This will undoubtedly give some people the wrong picture.

With 2 simple edits to the forum.module file, we enabled the exact functionality we were looking for: Control Forum Display using Access Roles, and Hide the Forums for those not authorized.

On line 41 of the forum.module file:
‘access’ => user_access(’access forums’), //changed from ‘access content’ to ‘access forums’ <- Our own defined permission

On line 131 of the forum.module file:
return array(’create forum topics’, ‘edit own forum topics’, ‘administer forums’, ‘access forums’); //added ‘access forums’ permission

Now all we have to do is go to: Administer >> User management >> Access control, and select the checkbox next to ‘access forums’ (under forum module) for each of the roles that we want to give forum access to.

December 10, 2007

Drupal: Custom Latest Posts

Filed under: Drupal, PHP — Soleer @ 10:29 pm

We’re currently developing a Drupal community website for an up-and-coming society.

On the community front page we wanted to display a list of the most recent forum posts. This can easily be accomplished using the Drupal API, and the forum_block() function, with the parameters ‘view’, and the 0 for most active posts, and 1 for newest post (i.e. forum_block(‘view’,0).

The problem in our situation was that we wanted to be able to customize the output beyond the standard API capabilities. In this case, it is a small customization, but this small customization involved digging deep into the Drupal PHP code. We wanted to display who posted the forum topic.

Here’s what we did:

<?php

/*Display Most Active Forum Posts*/

//sets variable to display 3 most active posts
variable_set(’forum_block_num_0′, ‘3′);

//SQL databse call, copied from forum_block(), added: n.uid which is the database value storing the user id of the poster
$sql = db_rewrite_sql(”SELECT n.nid, n.title, n.uid, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND n.type = ‘forum’ ORDER BY l.last_comment_timestamp DESC”);

//Get database results, and limit to number of posts defined by forum_block_num
$result = db_query_range($sql, 0, variable_get(’forum_block_num_0′, ‘5′));

//if the result isn’t empty, display the forum topics
if (db_num_rows($result)) {

     //for every row in the database, display the desired output
     while ($node = db_fetch_object($result)) {

           //create a user object, with the uid from the posting
           $user->uid = $node->uid;

           //take the partial user object, load a full user object, and get the username
           $user_name = user_load($user)->name;

           //create a link to the forum node, add ‘posted by’ with poster’s username
           $items[] = l($node->title, ‘node/’. $node->nid, $node->comment_count ? array(’title’ => format_plural($node->comment_count, ‘1 comment’, ‘@count comments’)) : ”).’ posted by: ‘.$user_name;
     }

//format the resulting list and return as content
     $content = theme(’node_list’, $items, $title);
}
echo $content; //return the formatted list of recent topics
?>

Who we are

Explore our history and character.

If you've ever been on a blind-date, odds are great that you know how disastrous "jumping before looking" can be. Feel free to do some online stalking here before you contact Soleer.

What We Do

"Girls only want boyfriends who have great skills." -Napoleon Dynamite

While we aren't looking to be your boyfriend and might not have "nunchuku skills," we do offer a number of other services and solutions to assist your organization.

What We’ve Done

As we say in Texas, "This ain't our first rodeo." Take a look at a sampling of some of our masterpieces, from logo design and brochure creation to webpage design and online community development.