• RICHARD ERIKSSON
  • LAST.FM
  • FLICKR

Just a Gwai Lo - fun within prescribed limits

  • home
  • about
  • ideas
  • photos
  • cherished
  • shared
  • elsewhere
  • contact
  • recent
Home

changelog

changelog

Changes

Unless the list is crazy long, like it can be for operating systems, I realized that I read software changelogs pretty closely. This site now has one, with an RSS feed. It will be a sort of commit message, listing additions and changes worth mentioning about the live site. (Can somebody remind me later on to tell you how I setup my staging environment? Yes, for a personal blog.) It will not include updates to Drupal modules run on the site unless it makes a dramatic difference. The changelog will include changes to layout or the underlying Drupal theme and addition of content sections. The first entry? That I created a changelog in the first place. You can find out which version of Drupal I'm running via the usual open secret method, though I will make a note of it when I do upgrade.

tags: Drupal, changelog

Interesting Site Note: Taglines

A few people have mentioned that my website's tagline changes from time to time, and have noted the wit they contain. (One even thought it was a running story, which isn't a bad idea actually, but few taglines are related to each other.) This site's tagline, technically the "slogan" in Drupal-speak, is often a turn of phrase from a rap song, but sometimes something that resonated with me from a text, like a book or article. A few months ago I set it up so that instead of manually changing the tagline through Administer » Site configuration » Site information, I could create a page that would automatically set the tagline's explanation. The advantages of that are many: I can create an RSS feed for tagline updates, tag each tagline, and refer to each explanation with a URL instead of having to go through it each time someone asked. And people could comment on each tagline.

How I Did It: CCK, Views, and Some Elbow Grease

The taglines, old and new, are available at http://justagwailo.com/taglines with an RSS feed at http://justagwailo.com/taglines/feed. To achieve that, I created a content type called "Taglines" with a description field using the CCK set of modules. Then I created a view using the Views set of modules, with an RSS feed argument. The hard part was getting it to automatically change the Drupal site slogan when I saved it, but the code that does it can be seen in the Fenchurch omnibus module I wrote. The relevant code is as follows:

<?php
/*
* The function takes the title of the most recently posted Tagline CCK content type. 
* Replace 'content_tagline' with the content type you are using to update your site's slogan with.
*/
function fenchurch_nodeapi(&$node, $op) {
 
$content_type = 'content_tagline';
  switch (
$op) {
    case
'submit':
    case
'insert':
      if (
$node->status == 1) {
       
$result = db_query("SELECT nid FROM node WHERE type = '%s' ORDER BY created DESC LIMIT 1", $content_type);
       
$nid = db_result($result);
        if (
$nid == $node->nid) variable_set('site_slogan', $node->title);
      }
      break;
   }
}
?>

(In your module you would have to change the function name to match the module name. For example, if the module is called arthur.module, you'd name the function arthur_nodeapi. I wrote it with a switch statement so that I can add functionality to it without having to restructure.)

Since the tagline appears on each page, it would need an explanation on each page. For that, I have the following code in the page.tpl.php file my theme (this is simplified from the code that currently runs) that creates an unobtrusive question mark people can click on to find out more, with instant gratification for those who hover their mouse over it.

<?php
$tagline_nid
= db_result(db_query("SELECT nid FROM {node} WHERE type = 'content_tagline' AND status = 1 ORDER BY created DESC LIMIT 1"));
$tagline_explanation = strip_tags(db_result(db_query("SELECT field_description_value FROM {content_field_description} WHERE nid = %d", $tagline_nid)));
print
'<small>[' . l("?", 'node/' . $tagline_nid, array('title' => $tagline_explanation)) . ']</small>';
?>

Briefly, the code above retrieves the ID of latest published tagline, then retrieves the data from it, strips out the HTML from the description, and wraps it in a link. It could use a little unpacking, since a lot happens on each line, and there's some magic using Content Template, if you understand PHP, you'll get the idea.

Search Engine Benefits

The site slogan, as it's called in Drupal, goes in the RSS feed added on to the title of the website, so anybody syndicating the site will likely have that in the link title. That often means that you will quickly rank highly for whatever you've set as your tagline, as I have for most of my site's taglines. It looks like I drop quite a bit in search engines for old taglines as soon as I change it, but at least with each tagline as a 'page' as far as their concerned, I'll still have a position in the search engines for my previous taglines. But more important for me is to have a record of when and why I changed what appears at the very top of my blog.

tags: Drupal, changelog, taglines

Interesting Site Notes: Introduction

Talking to Boris about this website last week, by way of a feature request he reminded me of both how overwhelming my site can look on first glance and how much stuff it hides from the front page. It also reminded me of an experiment I tried once with another website of mine: have a 'changelog'—that is, a list of changes made to something, usually software, with the most significant changes listed at the top, or prominently in some other way—in the sidebar of all modifications significant to warrant a mention. Both Boris and Darren calls making note of these changes "Boring Site Notes", but the geek in me likes these notices, as they alert me to things about the site that might have changed since the last time I actually visit them. So as homage, I will call my changelog "Interesting Site Notes", at least until I come up with a snootier phrase. I have an out-of-date colophon, but that's a static document. Boris suggested using 'diff' functionality to show the changes made to that what I consider a static document, something that accurately describes the current state of being, but which changes as the state of being changes.

(Via Kevin Marks' shared Google Reader items I read about an idea for a diff of all United States legislation. I want a version control system of the whole world, which is theoretically what the news media is supposed to provide.)

Changes to the site usually involve Drupal somehow, since most of the site is powered by the CMS. I'll post brief instructions, with PHP code where applicable, so that people can duplicate it if they feel like it. If any of the above or any of the following site notes confuse anybody, I'd love it if you asked me. I hate to think that I talk over people's heads—it happens, I know—and I love helping people discover new and interesting ways to discover new and interesting things!

tags: Drupal, changelog, diff
Syndicate content Syndicate content

License

Except for quoted text, Just a Gwai Lo is licensed under a Creative Commons Attribution 2.5 Canada License. A clearly-indicated direct link back to the original article is sufficient attribution. Just a Gwai Lo is powered by Drupal.

Web Analytics
  • home
  • about
  • ideas
  • photos
  • cherished
  • shared
  • elsewhere
  • contact
  • recent