Sugree

Main menu

  • About
    • Self
  • Project
    • Mitter
    • jibjib
    • microblog-purple
    • English
    • Thai

Getting the latest release of Drupal

Submitted by sugree on Tue, 03/18/2008 - 01:00
  • Drupal
  • English

markpeak has been trying to improve introduction page at Drupal Thailand. His UI design skill is being increased. One thing he needed is to have download buttons directly linked to the latest versions at drupal.org. For example, the front page of Drupal has links to both Drupal 6.1 and Drupal 5.7 (20080318 00:55). It is possible to implement the same at Drupal Thailand using php snippet to fetch information just like update_status did.

<?php
 
function _release_fetch($project, $core_version) {
  global $base_url;
 
  $available = array();
  $data = array();
 
  $site_key = md5($base_url . drupal_get_private_key());
  $baseurl = "http://updates.drupal.org/release-history";
 
  $url = $baseurl . "/" . $project . "/" . $core_version;
  if (!empty($site_key)) {
    $url .= (strpos($url, '?') === TRUE) ? '&' : '?';
    $url .= 'site_key=';
    $url .= drupal_urlencode($site_key);
  }
  $xml = drupal_http_request($url);
  if (isset($xml->data)) { 
    $data[] = $xml->data;
  }
 
  if ($data) {
    $parser = new update_status_xml_parser;
    $info = $parser->parse($data);
    $available = array_shift($info[$project]["releases"]);
  }
  return $available;
}
 
function _release_get_available($cores) {
  if (($cache = cache_get('intro_release_info', 'cache'))
      && $cache->expire > time()) {
    $available = unserialize($cache->data);
  }
  else {
    $project = "drupal";
    $available = array();
    foreach ($cores as $core) {
      $available[$core] = _release_fetch($project, $core);
    }
    cache_set('intro_release_info', 'cache', serialize($available), time() + (60 * 60 * 24));
    variable_set('intro_release_last', time());
  }
  return $available;
}
 
function _release_link($info) {
  return l("Drupal " . $info["version"], $info["download_link"]);
}
 
$available = _release_get_available(array("6.x", "5.x"));
 
?>

After this point you are able to generate a link as follow.

<?php print _release_link($available["6.x"]) ?>
<?php print _release_link($available["5.x"]) ?>

Note that above code is based on update_status module. In Drupal 6.x, update_status_xml_parser must be changed to update_xml_parser.

Roti thinks you may like these (alpha)
  • Welcome to Drupal 6
  • Drupal 6.4
  • [Drupal] Replace '(not verified)' to '(visitor)'
  • Dries Buytaert’s Vision of Drupal
  • Getting Started with VIM
by mk (not verified) on Tue, 03/18/2008 - 03:01 #121

Need to think about Download button design.

  • reply
by Вечерний макияж глаз фото (not verified) on Thu, 05/15/2008 - 15:41 #263

I not understend what U want

  • reply

Post new comment

The content of this field is kept private and will not be shown publicly.
Input format
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockcode> <pre>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <html>. Beside the tag style "<foo>" it is also possible to use "[foo]".
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <html>. Beside the tag style "<foo>" it is also possible to use "[foo]".
  • You can use Markdown syntax to format and style the text. Also see and Markdown Extra for tables, footnotes, and more.
  • Twitter-style @usersnames are linked to their Twitter account pages.
  • Twitter-style #hashtags are linked to search.twitter.com.

More information about formatting options

Popular Tags

Assumption BarCamp BarCampBangkok BarCampBangkok2 BarCampBkk2 ChipIn Django Drupal DrupalCamp DrupalCampBangkok Education Family Google Hardware Hardy Health Java jibjib Joke OpenOffice.org OpenSource Podcast Python Review SoC Social Network Trip Twitter Ubuntu Weekly Suki
more tags

Powered By

debian
apache
drupal
drupal.in.th
feedburner

© 2007-2008 Sugree Phatanapherom. Creative Commons [Feed Content / Comment]
RoopleTheme