Estrarre l'elenco dei link di un sito in Joomla

Può capitare di dover trasferire un sito creato con Joomla in un altro creato con un altro CMS. Per questo potrebbe servire di dover estrarre tutti i link presenti sul sito. Per farlo potete usare lo script qui sotto creato in PHP che stampa un elenco puntato con tutti i link e le relative descrizioni. Non è molto complicato e può essere modificato facilmente per stampare i dati in un modo diverso.
<?php
$ok = false;
include('configuration.php');
$config = new JConfig();
if($config->dbtype=='mysql'){
	$c = mysql_connect($config->host,$config->user,$config->password);
	if($c){
		if(mysql_select_db($config->db,$c)){
			$sql = 'SELECT * FROM '.$config->dbprefix.'weblinks WHERE published=1 AND approved=1 ORDER BY ordering';
			$res = @mysql_query($sql);
			unset($sql);
			if($res && mysql_num_rows($res)>0){
				$ok = true;
				echo '<ul>';
				while($r = mysql_fetch_assoc($res)){
					echo '<li><p><a href="'.$r['url'].'" target="_blank">'.trim($r['title']).'</a>'.(trim($r['description'])!='' ? '<br />'.nl2br(trim($r['description'])) : '').'</p></li>';
					unset($r);
				}
				echo '</ul>';
			}
			unset($res);
		}
	}
	unset($c);
}
unset($config);
if(!$ok){
	echo '<p>Errore.</p>';
}
unset($ok);
?>

Guida scritta da il 02/03/2011.

Le ultime guide della categoria Joomla:

comments powered by Disqus