Getting the latest release of Drupal
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.
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)





Need to think about Download button design.
I not understend what U want
Post new comment