Me parecía interesante ofrecer un bloque con los enlaces a las descargas de la web de Asterisk, el problema es que si pongo un bloque estático para cada nueva release de Asterisk voy a tener que estar actualizando las versiones.
Por este motivo me he decidido a hacer una pequeña plantilla para un bloque de Drupal, que coja los enlaces directamente de la web de Digium.
Para crear el bloque nos dirigimos a Administrar -> Configuración del sitio -> Bloques. Pulsamos luego en Añadir bloque y le ponemos una descripción (p.e. Descargas Asterisk) y seleccionamos el formato de entrada PHP Code.
En el cuerpo del bloque introducimos el siguiente código PHP:
<?php // v 0.2 lanzamiento Asterisk 1.6 beta // 19-01-2008 $dwnblk=false; $print=false; $fp =fopen("http://www.asterisk.org/downloads", "r"); if (!$fp) { echo "No disponible en este momento"; } else { while (!feof($fp)) { $line = fgets($fp, 255); if (substr($line,0,strlen($line) - 1) == '<div class="block block-block" id="block-block-10">') $dwnblk=true; if (substr($line,0,strlen($line) - 1) == '</div>') { $dwnblk=false; $print=false; } if ($dwnblk) { if (strstr($line,"<h5>")) { $print=true; $lc=0; } } if ($print) { $lc++; if ($lc == 1) { $ver=substr($line,strlen($line) - 9,3); $html="<b>Versión ".$ver."</b>"; } else if ($lc == 2) { echo "<ul>"; $html=str_replace("<p>","<li>",$line); $html=str_replace("<br />","</li>",$html); $html=str_replace('target="_blank"','rel="nofollow"',$html); } else if ($lc == 3 or $lc ==4) { $html=str_replace("<a","<li><a",$line); $html=str_replace("<br />","</li>",$html); $html=str_replace('target="_blank"','rel="nofollow"',$html); } else if ($lc == 5) { $html=str_replace("<a","<li><a",$line); $html=str_replace("</p>","</li></ul>",$html); $html=str_replace("</div></div></div>","",$html); $html=str_replace('target="_blank"','rel="nofollow"',$html); $print=false; } echo $html; } } } ?>
En la página de los bloques vamos a Configurar y le ponemos un título al bloque, luego le damos una ubicación y ya hemos acabado. Ahora tenemos disponible un bloque como el que tenéis a vuestra derecha.