DrupalCon Boston 2008: Day1

I have the distinct pleasure of attending DrupalCon 2008, which is being held in Boston, MA this year. This year's attendance has blown out the attendance levels of previous DrupalCons, and it is a testament to the growing popularity of Drupal as a content management system.

The sessions I attended today were:

Design on the Edge of Drupal
This session was principally for designers, and talked about taking inspiration from architecture to build Drupal websites that are anything but standard. The point of the presentation was that a Drupal site does not have to look like a Drupal site, as long as users of the site have an expectation of how to navigate and get around.

Enterprise Theming in Drupal
As the engineering manager for Greenopolis, an environmentally-themed social networking site built 100% in Drupal, this session was very informative. We have thousands of nodes and users, and the purpose of this session was how to take a very large site and segment it thematically for the purposes of monetizing your audience.

Mapping Business Requirements to Drupal Modules
This session covered the basic problem of taking what the customer has asked you to build, and applying a development planning process for meeting those business goals.

Drupal Multimedia
As I continue to work on Greenopolis, one of the challenges I face is how to implement multimedia, especially in user-generated content. Performance and security are always major concerns, and this session provided a wealth of information regarding the options available to Drupal developers, as well as techniques for accomplishing some of this kind of functionality.

I will be attending DrupalCon on Tuesday and Wednesday, and post more information as the conference progresses.

Cell Phone Aggravation

I finally broke down and bought a cellphone.

Nothing fancy, just a Sanyo SCP-3200 with Sprint as the carrier. There is nothing spectacular about this phone; it's got basic functionality, it's small and lightweight, and is a good solution for someone who doesn't like to talk on the phone in the first place.

Sadly, this phone had an unfortunate interaction with the inside of a toilet bowl, resulting in the white screen of death. Despite having been submerged in water for less than two seconds, the screen was completely shot, a victim of "massive water damage."

Fortunately, the screen was the only part of the phone that was damaged, but it could not be repaired, so I purchased a new phone of the same model. My new problem was how to get my contacts and other data off the old phone. Stupidly, I went to Radio Shack to purchase a data cable for $9.99. The data cable came with the HandsetManager software, which the manager at RadioShack said would help me retrieve my data from the broken cell phone.

Much to my dismay, the manager did not know the product he sold me, or else he would have known that the software does not support my phone. After searching the internet for a few hours, it became clear that a lot of people did not know how to connect their computer to the SCP-3200.

One tip led me to DataPilot, which is not free. Despite paying for a data cable and software, I had to shell out another $39.95 for the DataPilot software, which was risky considering the fact that I had no idea if it would work or not. Out of the box, this software did not support my phone. I had to update the software several times and from several different places before I could finally connect to my phone. Once I was able to do that, the software did a good job of reading the data from the phone, allowing me to edit the data and save it to my computer, and then send the data to the new cell phone.

The user interface is not the best, being neither intuitive nor visually appealing. However, it is very functional software, except it does not support ringtone editing on my phone, or photo editing. These pieces of missing functionality don't bother me though, as I use neither function on my phone.

So the bottom line is, if you need to connect to a Sanyo SCP-3200 cell phone, one solution is to purchase a data cable and DataPilot, and make sure you update the software after purchasing it.

[tags]cell+phone, DataPilot, HandsetManager, RadioShack, Sanyo, SCP-3200, Sprint, water+damage[/tags]

Drupal: Incorrect Pager Results

I've been working on a Drupal module that generates a search form and presents the results below the form. However, I ran into a strange issue where the database query returned 3 records, and yet, the pager was displaying 9 pagination links.

The code that builds and handles the query looks like this:


<?php
$query 
'select
  n.nid,
  n.title,
  DATE_FORMAT(FROM_UNIXTIME(n.created), \'%c/%e/%Y\') as created,
  c.field_product_price_value as price,
  d.name,
  t.tid
from
  {node} n
  left join {node_revisions} r on r.vid = n.vid
  left join {content_type_galleria_product} c on c.nid = n.nid
  left join {term_node} t on t.nid = n.nid
  left join {term_data} d on d.tid = t.tid '
;

$groupby ' group by n.nid';
$clauses = array();
$clauses[] = 'n.type = \'galleria_product\'';
   
foreach(
$form_values as $key => $value)
{   
  if((
$key) && ($value != ''))
  {
    switch(
$key)
    {
      case 
'name':
        
$clauses[] = 'n.title like \'%%'.db_escape_string($value).'%%\'';
        break;
      case 
'price_range':
        
$clauses[] = 'c.field_product_price_value <= '.db_escape_string($value);
        break;
      case 
'category':
        
$clauses[] = 't.tid = '.db_escape_string($value);
        break;
      case 
'created':
        switch(
$value)
        {   
          case 
'today':
            
$clauses[] = 'DATE(FROM_UNIXTIME(n.created)) = CURDATE()';
            break;
          case 
'current_week':
            
$clauses[] = 'WEEK(FROM_UNIXTIME(n.created)) = WEEK(NOW())';
            break;
          case 
'current_month':
           
$clauses[] = 'MONTH(FROM_UNIXTIME(n.created)) = MONTH(NOW())';
           break;
         case 
'current_year':
           
$clauses[] = 'YEAR(FROM_UNIXTIME(n.created)) = YEAR(NOW())';
           break;
       }
       break;
     default:
       break;
    }
  }
}
   
$limit 30;
$header = array(
  array(
'data' => t('Name'), 'field' => 'n.title''sort' => 'asc'),
  array(
'data' => t('Rating')),
  array(
'data' => t('Price'), 'field' => 'c.field_product_price_value'),
  array(
'data' => t('Category'), 'field' => 'd.name'),
  array(
'data' => t('Created'), 'field' => 'n.created')
);
   
$query .= (count($clauses) ? 'WHERE ' implode(' AND '$clauses) : '');
$tablesort tablesort_sql($header);
$result pager_query($query.$groupby.$tablesort$limit0);
$rows = array();
 
// Retrieve all the data found by the query
while($data db_fetch_array($result))
{
  
$current_avg votingapi_get_voting_results('node'$data['nid'], 'percent''vote''average');
  
$stars variable_get('fivestar_stars_'. (!isset($node) ? 'default' $node->type), 5);
  
$rows[] = array(
    
l($data['title'], 'node/'.$data['nid']),
    
theme('fivestar_static'$current_avg[count($current_avg)-1]->value$stars),
    
'$'.$data['price'],
    
l($data['name'], 'taxonomy/term/'.$data['tid']),
    
$data['created'],
  );
}
   
if(empty(
$rows))
{
  
$rows[] = array(array('data' => t('Your search failed to find any products.'), 'colspan' => 3));
}

$output theme('table'$header$rows);
$output .= theme('pager'null$limit);
?>

After banging my head against the wall for a few hours, I came across a post by Kris Buytaert which explained why I was seeing this problem.

To summarize, the code that produces the pagination links is in pager.inc. Within this code is this bit:


<?php

$count_query 
preg_replace(array('/SELECT.*?FROM /As''/ORDER BY .*/'), array('SELECT COUNT(*) FROM '''),$query);

?>

You'll note that the pattern matching is case insensitive. As my query was written all in lowercase, the pagination code was not matching anything. All I had to do was rewrite the query such that the MySQL keywords were in uppercase.

A bug, to be sure, considering that the SQL Standard does not call for specific case. As pager.inc is part of the Drupal core, hopefully it will get patched and fixed soon.

[tags]Drupal, module, pager, query[/tags]

Drupal: Releasing Custom Modules

I recently built my first module for Drupal, which exposes data from the Userpoints module to Views. There was some talk with the CEO of my company about releasing the module to the community as a contributed module, and some hedging about whether to release it or not.

Releasing modules shouldn't even be a topic of discussion within a company. The work I did on this module was built off the many, many, many hours others have spent on Userpoints and Views. In addition, thousands of developers contributed to, and continue to contribute to Drupal. For a company to even consider taking an Open Source project, developing a feature on top of it and then not releasing it, is rude and insulting to all the developers that have work on this OSS project.

Companies who use Drupal and other open source software have directly benefited from the work of thousands. These companies have saved gobs and gobs of cash by stating with Drupal as a base and then building on top. That base was built by ordinary people, and that base depends upon people contributing their code.

Credit should be given where it is due and if your company has sponsored the development of Drupal modules by paying your salary, that should be mentioned. At the very least, your company's name can be in the module itself with the README file and within the code.

Again, this should not even be a topic of discussion. If you work with Drupal and extend its functionality, release the code to the community.

Drupal, PHP, modules, extend, oss, open-source, software, philosophy, release, community

Drupal: Loading custom userprofile data

I have found that the core Drupal profile module provides very limited customization possibilities. However, the Usernode and Nodeprofile modules help out immensely with this.

If you want access to custom user profile fields, such as CCK fields, you simply load the profile:


<?php
$usernode 
nodeprofile_load('uprofile'$node->uid);
?>

Drupal, PHP, Usernode, Nodeprofile, user+profile, Image

Drupal: Calling Views In Code

Drupal is a fairly flexible system as far as CMS applications go, and is even more flexible as a development platform. The Views module gives developers ways to dynamically build queries of data, and display that data in many different ways. Sometimes, however, you want to display views in ways not supported through the admin interface. Fortunately, there are other ways to get the job done.

For example, I have a block in my sidebar where I want to display a list of the latest blog post, latest forum topic, and latest user poll. Each of these lists can be created as separate views. However, there doesn't seem to be any functionality, either in the Views module or another third-party module, that allows you to display multiple unrelated views in a single block. So, we turn to the code. The Views API provides a mechanism for building and displaying your views anywhere in your templates:


<?php views_get_view($name_of_view); ?>

and

<?php views_build_view($type$view$view_args$use_pager$node_limit); ?>

Clearly, the views_get_view() function retrieves the view definition from the database, while the views_build_view() function renders it.

Back to my example - I simply created a new block, and set the input format to PHP. Then, I used the following code to populate the block with the views:

<?php
<h2>Latest Blog Post:</h2>
<?
php  echo views_build_view('embed'views_get_view('latest_blogpost'), nullfalse1); ?>
<h2>Latest Forum Topic:</h2>
<?php echo views_build_view('embed'views_get_view('latest_forumtopic'), nullfalse1); ?>
<h2>Latest Poll:</h2>
<?php echo views_build_view('embed'views_get_view('latest_userpoll'), nullfalse1); ?>

The above code shows the rendered view. However, there are times where you want or need to do some additional processing on the values returned by the view. Fortunately, the Views module is incredibly powerful, and has a ton of options for retrieving the views.

In the above example, the first argument to the views_build_view() function is 'embed'. There are several other options:

  • page - Produces output as a page, sent through the theme. The only real difference between this and block is that a page uses drupal_set_title to change the page title.
  • block - Produces output as a block, sent through the theme
  • embed - Use this if you want to embed a view onto another page, and don't want any block or page specific things to happen to it.
  • result - Returns an array of information, including a database object that you can use db_fetch_object() on
  • items - Returns an array like resul, however, it contains an array of objects found by the queries, so you don't have to fetch the objects yourself.
  • queries - returns an array, summarizing the queries, but does not run them

This information comes directly from the code, and hopefully, it will be of some assistance to people who are looking for this kind of functionality.

[tags]block, cms, development, drupal, php, templates, Views[/tags]

Erich Joins the Staff at CommonPlaces e-Solutions, Inc.

I am excited to announce that I will be joining the very talented staff at CommonPlaces e-Solutions, Inc. on September 19, 2007 as Senior Internet Engineer.

I will remain a part of the ResortScope.com team as a consultant, and will continue to build out new features and services for both ResortScope and the TotalScope Resort Marketing parent company.

This is a tremendous opportunity for me, and I look forward to working on some very large projects there!

Bipolar


NH-based hard rock band Mindset X has just released their fifth CD entitled "Bipolar".

This five-song EP is musically different from the band's previous efforts, and is a bit more in the vein of traditional hard rock. What remains unchanged however is the incredible lyrics; intelligent and thought-provoking.

I did the artwork for this CD, along with the artwork for all of the band's other releases, and the work was done with Photoshop. I'm quite proud of the artwork, and I hope that you like it as well.

Support local music, and support Mindset X by purchasing this CD!

[tags]artwork, band, beyrent, bipolar, cd, metal, mindset+x, music, nh, photoshop, release, rock[/tags]

Timeflow

30 years ago, a baby clung to life
with the tenacity of someone never touched
by failure, pain, or fear and it was plain
to all who saw him that this infant would be
something special

20 years ago, a boy dreamed of spaceflight
as a given, the next natural progression
to reach the planets and move beyond the boundries
of his ancestors' existence
The dream shattered with the exploding shuttle
and snuffed the fires of passion with tears

10 years ago, a young man had it all
A promising future
success and confidence fueled his drive
until the day his body betrayed him
and cut short the future
that was all but promised

Today, a man goes to work chained and shackled
by the echoes of mediocrity and missed opportunity
Bound by obligation, the man is dead to the dreams
of the young, forced to keep his eyes down
to avoid being swept away by responsibility

10 years from now, a man grows old before his time,
dying a little more each day
Accutely aware of a life passing by, he laments
the lack of accomplishments to his name

Is simply being a good man enough for satisfaction
or does pride demand more?

beyrent, poetry, writing

IE7 RSS Auto-discovery

I recently built an RSS feed for work, and noticed that in IE 7, the RSS toolbar button was not lit up. A little research on the Microsoft Team RSS blog showed me the solution. Add the following to the section of your website:

[html][/html]

[tags]blog, feed, IE, microsoft, rss, web, xml[/tags]

About Erich

Erich is a web developer and a native New Englander who is passionate about life, the universe, and everything.

He is currently a senior Drupal developer at Harvard University, working on the IQSS OpenScholar project.  Prior to joining the team at Harvard, he was the engineering manager at CommonPlaces e-Solutions, in Hampstead, NH, contributing as the lead engineer on the Greenopolis.com and Twolia.com.

Erich is active in the Drupal community, having contributed modules and patches to the community. He presented at DrupalCon in Szeged Hungary, and co-presented at DrupalCon 2009 in Washington, DC.

Erich lives in New Hampshire with his wife, two sons, and two weimaraners.  When not writing code, Erich enjoys landscaping and woodworking.

Faceted search

Categories

Content type

Project types

Artwork Type

Artwork Tags

Recent comments

Activity Stream

August 2, 2010

  • Twitter ebeyrent tweeted "@cpliakas I'm apparently valued on the open market at $737. I feel cheap now; gonna go take a shower." 8:08pm #
  • Twitter ebeyrent tweeted "Having some real stability issues with the Helios release of #eclipse." 1:22pm #
  • Twitter ebeyrent tweeted "RT: @DamienMcKenna: RT @markboulton: http://whatthefuckismysocialmediastrategy.com/ Genius. (via @alexjamesmorris)" 10:38am #
  • Twitter ebeyrent tweeted "@shaunsutherland @starshaped @cpliakas @ericlondon @webkenny Count me in!!!" 8:58am #
  • Twitter ebeyrent tweeted "@leahcreates Why do you think I do it? :o)" 7:43am #
  • Twitter ebeyrent tweeted "@shaunsutherland I'm both sad and happy for you - it was great to work with you. When's your last day at CP, and when are you moving?" 7:43am #

August 1, 2010

  • Twitter ebeyrent tweeted "I don't mind doing laundry, but folding sheets sucks." 8:38pm #
  • Twitter ebeyrent tweeted "1408 is one of the worst movies I have ever seen." 2:06pm #

July 31, 2010

  • Twitter ebeyrent tweeted "@shaunsutherland Where are you off to?" 11:00pm #
  • Twitter ebeyrent tweeted "In the Bronx, stabbing is just another form of arguing." 10:59pm #

May 28, 2010

  • Twitter ebeyrent tweeted "@j_macdonald Thanks for the heads-up. It's fixed now..." 6:25am #

May 27, 2010