- Home
- Categorie
- La Community Connect.gt
- News Ufficiali da Connect.gt
- Creare un Feed
-
Creare un Feed
Ecco la mia domanda:
io vorrei creare un feed rss in modo che i navigaotiri del mio sito rimangano sempre aggiornati degli articoli che inseirisco nuovi e tempo qualcuno del forum aveva postato un sito che creava un feed rss della pagina del proprio sito ma non ricordo dov'è finito.
Qualcuno sa aiutarmi
-
-
Per iniziare, ti posso suggerire un programma freeware da eseguire in locale: http://www.phelios.net/rss-writer.html
Cordialmente,
Stuart
-
Mi accodo nel proporre programmi freeware
http://home.hetnet.nl/~bsoft/rssbuilder/index.htm
Per farlo direttamente dal sito, invece, le pagine devono avere una struttura tale da essere analizzate correttamente, e qualcosa non va mai per il verso giusto.
-
E rilancio con un altro freebie, questa volta è una classe php da far girare sul server:
http://www.bitfolge.de/rsscreator-en.html@m4rc0 said:
Per farlo direttamente dal sito, invece, le pagine devono avere una struttura tale da essere analizzate correttamente...
Purtroppo.Cordialmente,
Stuart
-
Ho dimenticato di dirvi che uso Mambo, non so se cambia qualcosa
-
ma mambo non ce l'ha giá un feed?
-
@must said:
ma mambo non ce l'ha giá un feed?
Si però non capisco come fare per crearlo che mi aggiorni solo gli ultimi articoli inseriti...c'è qualcuno che sa farlo?
Grazie :bho:
-
@riga75 said:
Si però non capisco come fare per crearlo che mi aggiorni solo gli ultimi articoli inseriti...c'è qualcuno che sa farlo?
Grazie :bho:
hai le pagine organizzate in un db?
-
-
adatta questa pagina rss.php e linkala
<?php
include ( "../funzioni.php" );
include('makerss.php');
$myDB=ConnectionDB( $option['host'],$option['user_db'],$option['pass_db'],$option['database']);
$r = new MakeRSS('Feed RSS di sito.it', 'http://www.sito.it', 'descrizione feed rss');
$result=mysql_query("SCRIVI QUI LA QUERY PER ESTRARRE GLI ARTICOLI");
echo mysql_error();
while($row=mysql_fetch_array( $result)){
$url="http://" .$option['server']. $row["path"]."/". $row["file_name"];
$r->AddArticle(str_replace('?','Euro',$row["titolo"]), $url, str_replace('?','Euro','descrizione articolo............'), 'Autore');
}
$r->Output();
?>makerss.php
<?php class MakeRSS{ var $Articles = array(); // Channel info var $title = ''; var $link = ''; var $description = ''; var $optional = array(); var $image = array('url' => '', 'title' => '', 'link' => '', 'description' => '', 'w' => 0, 'h' => 0); function MakeRSS($title, $link, $description, $optional = ''){ $this->title = $title; $this->link = $link; $this->description = $description; if( is_array($optional) and count($optional) ){ $this->optional = $optional; } } function AddOptional($key, $value){ $this->optional[$key] = $value; } function AddImage($title, $url, $link, $description = ''){ $this->image['title'] = $title; $this->image['url'] = $url; $this->image['link'] = $link; $this->image['description'] = $description; if( $tmp = @getimagesize($url) ){ $this->image['w'] = ($tmp[0] > 144) ? 144 : $tmp[0]; $this->image['h'] = ($tmp[1] > 400) ? 400 : $tmp[1]; } } function AddArticle($title, $link, $description, $author, $optional = ''){ $i = array_push($this->Articles, array('title' => $title, 'link' => $link, 'description' => $description, 'author' => $author)); if( is_array($optional) and count($optional) ){ --$i; while( list($k, $v) = each($optional) ){ $this->Articles[$i][$k] = $v; } } } function Output($save = false, $path = ''){ $out = '<?xml version="1.0"?>' . "\n" . '<rss version="2.0">' . "\n" . '<channel>' . "\n"; $out .= "<title>$this->title</title>\n" . "<link>$this->link</link>\n" . "<description>$this->description</description>\n"; //Channel optionals if( is_array($this->optional) and count($this->optional) ){ while( list($k, $v) = each($this->optional) ){ $out .= "<$k>$v</$k>\n"; } } //Image if( $this->image['title'] and $this->image['url'] and $this->image['link'] ){ $out .= "<image>\n" . "<title>" . $this->image['title'] . "</title>\n" . "<url>" . $this->image['url'] . "</url>\n" . "<link>" . $this->image['link'] . "</link>\n"; if( $this->image['description'] ){ $out .= "<description>" . $this->image['description'] . "</description>\n"; } if( $this->image['w'] and $this->image['h'] ){ $out .= "<width>" . $this->image['w'] . "</width>\n" . "<height>" . $this->image['h'] . "</height>\n"; } $out .= "</image>\n"; } //Articles for( $i = 0, $c = count($this->Articles); $i < $c; $i++ ){ $out .= "<item>\n" . "<title>" . $this->Articles[$i]['title'] . "</title>\n" . "<link>" . $this->Articles[$i]['link'] . "</link>\n" . "<description>" . $this->Articles[$i]['description'] . "</description>\n" . "<author>" . $this->Articles[$i]['author'] . "</author>\n"; if( count($this->Articles[$i]) > 4 ){ while( list($k, $v) = each($optional) ){ if( !in_array($k, array('title', 'link', 'description', 'author')) ){ $out .= "<$k>$v</$k>\n"; } } } $out .= "</item>\n"; } $out .= "</channel>\n</rss>"; // True output if( !$save or !$path ){ header("Content-type: application/xml"); echo $out; return true; } else{ $fh = fopen($path, 'w'); if( $fh ){ fwrite($fh, $out); fclose($fh); return true; } return false; } } } ?>
-
Intanto grazie Rinzi
Visto che sono un pò ignorantotto, queste sono le mie domande:
questo dove lo metto, e sto file qua (include ( "../funzioni.php" );) cos'è?
@"Rinzi" said:<?php
include ( "../funzioni.php" );
include('makerss.php');
$myDB=ConnectionDB( $option['host'],$option['user_db'],$option['pass_db'],$option['database']);
$r = new MakeRSS('Feed RSS di sito.it', 'http://www.sito.it', 'descrizione feed rss');
$result=mysql_query("SCRIVI QUI LA QUERY PER ESTRARRE GLI ARTICOLI");
echo mysql_error();
while($row=mysql_fetch_array( $result)){
$url="http://" .$option['server']. $row["path"]."/". $row["file_name"];
$r->AddArticle(str_replace('?','Euro',$row["titolo"]), $url, str_replace('?','Euro','descrizione articolo............'), 'Autore');
}
$r->Output();
?>
Qesto se non ho capito male è il file che mi crea il feed?
Ossia l'icone del feed deve puntare a questo file?
[quote=Rinzi]
makerss.php<?php class MakeRSS{ var $Articles = array(); // Channel info var $title = ''; var $link = ''; var $description = ''; var $optional = array(); var $image = array('url' => '', 'title' => '', 'link' => '', 'description' => '', 'w' => 0, 'h' => 0); function MakeRSS($title, $link, $description, $optional = ''){ $this->title = $title; $this->link = $link; $this->description = $description; if( is_array($optional) and count($optional) ){ $this->optional = $optional; } } function AddOptional($key, $value){ $this->optional[$key] = $value; } function AddImage($title, $url, $link, $description = ''){ $this->image['title'] = $title; $this->image['url'] = $url; $this->image['link'] = $link; $this->image['description'] = $description; if( $tmp = @getimagesize($url) ){ $this->image['w'] = ($tmp[0] > 144) ? 144 : $tmp[0]; $this->image['h'] = ($tmp[1] > 400) ? 400 : $tmp[1]; } } function AddArticle($title, $link, $description, $author, $optional = ''){ $i = array_push($this->Articles, array('title' => $title, 'link' => $link, 'description' => $description, 'author' => $author)); if( is_array($optional) and count($optional) ){ --$i; while( list($k, $v) = each($optional) ){ $this->Articles[$i][$k] = $v; } } } function Output($save = false, $path = ''){ $out = '<?xml version="1.0"?>' . "\n" . '<rss version="2.0">' . "\n" . '<channel>' . "\n"; $out .= "<title>$this->title</title>\n" . "<link>$this->link</link>\n" . "<description>$this->description</description>\n"; //Channel optionals if( is_array($this->optional) and count($this->optional) ){ while( list($k, $v) = each($this->optional) ){ $out .= "<$k>$v</$k>\n"; } } //Image if( $this->image['title'] and $this->image['url'] and $this->image['link'] ){ $out .= "<image>\n" . "<title>" . $this->image['title'] . "</title>\n" . "<url>" . $this->image['url'] . "</url>\n" . "<link>" . $this->image['link'] . "</link>\n"; if( $this->image['description'] ){ $out .= "<description>" . $this->image['description'] . "</description>\n"; } if( $this->image['w'] and $this->image['h'] ){ $out .= "<width>" . $this->image['w'] . "</width>\n" . "<height>" . $this->image['h'] . "</height>\n"; } $out .= "</image>\n"; } //Articles for( $i = 0, $c = count($this->Articles); $i < $c; $i++ ){ $out .= "<item>\n" . "<title>" . $this->Articles[$i]['title'] . "</title>\n" . "<link>" . $this->Articles[$i]['link'] . "</link>\n" . "<description>" . $this->Articles[$i]['description'] . "</description>\n" . "<author>" . $this->Articles[$i]['author'] . "</author>\n"; if( count($this->Articles[$i]) > 4 ){ while( list($k, $v) = each($optional) ){ if( !in_array($k, array('title', 'link', 'description', 'author')) ){ $out .= "<$k>$v</$k>\n"; } } } $out .= "</item>\n"; } $out .= "</channel>\n</rss>"; // True output if( !$save or !$path ){ header("Content-type: application/xml"); echo $out; return true; } else{ $fh = fopen($path, 'w'); if( $fh ){ fwrite($fh, $out); fclose($fh); return true; } return false; } } } ?>
-
e sto file qua (include ( "../funzioni.php" )OK cos'è?
è solo un file in cui imposto alcune variabili da utilizzare in tutto il sito
come $option['user_db'] per la connessione al DBpuoi eliminare quest include
e sostituire
$myDB=ConnectionDB( $option['host'],$option['user_db'],$option['pass_db'],$option['database']);
con
$myDB=ConnectionDB( 'DBhost','user_db','pass_db','database');
il primo blocco di codice lo metti un un file che si chiama** rss.php** (o simile)
e lo link dal sitoQesto se non ho capito male è il file che mi crea il feed?
Ossia l'icone del feed deve puntare a questo file?rss.php è il file che devi linkare e che crea il feed
l'altro viene utilizzato dal prima ma nn devi linkarlo direttamente (mettilo nella stessa cartella)
ci siamo
( ero stato impreciso io
)
se ci siamo nn andiamo OT