No pues ya va quedando el modulo solo que ahora tengo problemas a la hora de presentar la informacion en este caso un Rss especifico para 1 solo nodo o categoria especial, pues tengo lo siguiente:
al ir a la ruta de drupal ejem: http://drupal/personal_rss/node/x deberia obtener el rss de este pero me marca un error alguna idea de como pueda lograrlo,otra pregunta drupal es compatible con clases de php aparte y de ser asi como combino ambos con sus funciones asi seria mas facil jejejeje ,de antemano gracias estare al pendiente a el erro que me sale en este caso en este ejemplo uso personal_rss/data y deberia salir un xml en mod browser pero dice Error de lectura XML: declaración de texto o XML en un lugar distinto del principio de la entidad
Ubicación: http://localhost/drupal-6.20/personal_rss/data
Número de línea 55, columna 14: <?xml version = "1.0" encoding = "utf-8"?><rss version ="2.0"><channel><title>RandomChannel2</title><description>RandomDescription2</description><language>es-mx</language><link>http:localhost/drupal</link><item><title>TEST2</title><link></link><description>Así como el primer juego de la serie de Parasite Eve ya llegó a la PlayStation Network, ahora tenemos noticias de que la segunda parte también arribará de manera digital al servicio.
-------------^
<?php
/**
* @author KiRa
* @copyright 2011
*/
/**
* Implementation of hook_menu
*
* This menu is displaying in new part of admin/menus, this realize part of registration de new feed in the block
*/
function personal_rss_menu()
{
$items = array();
$items['personal_rss'] = array('title' => 'Personal RSS', 'description' =>
'Display the most interesting in newa in format RSS.', 'access callback' =>
'user_access', 'access arguments' => array('access content'), 'page callback' =>
'x_item', );
//REALIZANDO LA LLAMADA A UN ARCHIVO
$items['personal_rss/rss.xml'] = array('title' => 'Personal RSS test1',
'description' => 'Display the most interesting in newa in format RSS.', 'file' =>
'ejemplo.php', 'access arguments' => array('access content'), );
//generando la llamada desde el propio modulo
$items['personal_rss/node'] = array('title' => 'Personal RSS test 2',
'description' => 'Display the most interesting in news in format RSS.',
'access callback' => 'user_access', 'access arguments' => array('access content'),
'page callback' => '_personal_rss_mkRSS', );
return $items;
}
//////////////////////////
function x_item()
{
$result = db_query("SELECT node.nid AS Nid, node.LANGUAGE AS \"Language\"\n" .
" , node . title AS Title, node_revisions . teaser AS Description,FROM_UNIXTIME(node.created,\"%a, %d %M %Y %h:%i:%s GTM\") AS pubdate\n" .
" FROM node INNER JOIN node_revisions ON node . nid = node_revisions . nid");
$data = db_fetch_array($result, MYSQL_BOTH);
return $data['pubdate'] . '<br/>' . $data['Language'] . '<br/>' . $data['Nid'] .
'<br/>' . $data[1]['Title'] . '<br/>' . $data['Description'] . '<br/>' . count($data) .
'<br/>otro';
}
/////////////////////////////////////////////////////////////
function _personal_rss_mkRSS() /**$nid,*/
{
$rss = array();
$url = 'http://localhost/drupal-6.20/node/';
$result = db_query('SELECT node.nid AS Nid, node.LANGUAGE AS "Language"
, node . title AS Title, node_revisions . teaser AS Description,FROM_UNIXTIME(node.created,"%a, %d %M %Y %h:%i:%s GTM") AS pubdate
FROM {node} INNER JOIN {node_revisions} ON node . nid = node_revisions . nid');
$data = db_fetch_array($result);
if (!$data) {
echo 'FATAL ERROR : DONT COULD CONNECT THE DB ';
} else {
/////////seccion 1 solo elemento////////////////
if (count($data) <= 0) {
$rss[] = ' <? xml version = "1.0" encoding = "utf-8" ?>';
$rss[] = '<rss version ="2.0">';
//seccion Channel
$rss[] = '<channel>';
$rss[] = sprintf('<title>%s</title>', 'RandomChannel1');
$rss[] = sprintf('<description>%s</description>', 'RandomDescription1');
$rss[] = sprintf('<language>%s-mx</language>', 'es');
$rss[] = sprintf('<link>%s</link>', $url . $data['Nid']);
//seccion Item
$rss[] = '<item>';
$rss[] = sprintf('<title>%s</title>', $data['Title']);
$rss[] = sprintf('<link>%s</link>', $url . $data['Nid']);
$rss[] = sprintf('<description>%s</description>', $data['Description']);
$rss[] = sprintf('<pubDate>%s</pubDate>', $data['pubdate']);
//end tags item,channel and rss
$rss[] = '</item>';
$rss[] = '</channel>';
$rss[] = '</rss>';
return _export('browser', $rss, '');
} else {
//para mas de un objeto
$lenght = count($data);
$rss[] = ' <?xml version = "1.0" encoding = "utf-8"?>';
$rss[] = '<rss version ="2.0">';
//seccion Channel
$rss[] = '<channel>';
$rss[] = sprintf('<title>%s</title>', 'RandomChannel2');
$rss[] = sprintf('<description>%s</description>', 'RandomDescription2');
$rss[] = sprintf('<language>%s-mx</language>', 'es');
$rss[] = sprintf('<link>%s</link>', 'http:localhost/drupal');
//seccion Item
//para futuras expansiones de esta funcion para mas items solo realiazar lo de la clase kml
$rss[] = '<item>';
$rss[] = sprintf('<title>%s</title>', $data['Title']);
$rss[] = sprintf('<link>%s</link>', $data['linkItem']);
$rss[] = sprintf('<description>%s</description>', $data['Description']);
$rss[] = sprintf('<pubDate>%s</pubDate>', 'Tue, 22 March 2011 01:30:35 GTM');
//end tags item,channel and rss
$rss[] = '</item>';
$rss[] = '</channel>';
$rss[] = '</rss>';
return _export('browser', $rss, '');
}
}
}
function _export($mode = 'browser', $xml = array(), $path_to_file)
{
switch ($mode) {
case 'download':
header("Content-type: text/xml");
header("Pragma: public");
header("Cache-control: private");
header("Expires: -1");
header("Content-Disposition: attachment; filename=rss.xml");
header("Content-Type: application/force-download");
exit($xml);
break;
case "write":
if (empty($path_to_file))
return "No file destination was given.";
if (!file_exists($path_to_file))
if (!touch($path_to_file))
return "Unable to create the file '$path_to_file'.";
if (!$file = fopen($path_to_file, "wb"))
return "Unable to open file '$path_to_file' for writing.";
if (!fwrite($file, $this->rss))
return "Unable to write contents to file '$path_to_file'.";
if (!fclose($file))
return "Unable to close the file '$path_to_file'.";
return true;
default:
header("Content-type: text/xml");
header("Pragma: public");
header("Cache-control: private");
header("Expires: -1");
$output = join($xml);
return $output;
}
}
?>
/**
* @author KiRa
* @copyright 2011
*/
/**
* Implementation of hook_menu
*
* This menu is displaying in new part of admin/menus, this realize part of registration de new feed in the block
*/
function personal_rss_menu()
{
$items = array();
$items['personal_rss'] = array('title' => 'Personal RSS', 'description' =>
'Display the most interesting in newa in format RSS.', 'access callback' =>
'user_access', 'access arguments' => array('access content'), 'page callback' =>
'x_item', );
//REALIZANDO LA LLAMADA A UN ARCHIVO
$items['personal_rss/rss.xml'] = array('title' => 'Personal RSS test1',
'description' => 'Display the most interesting in newa in format RSS.', 'file' =>
'ejemplo.php', 'access arguments' => array('access content'), );
//generando la llamada desde el propio modulo
$items['personal_rss/node'] = array('title' => 'Personal RSS test 2',
'description' => 'Display the most interesting in news in format RSS.',
'access callback' => 'user_access', 'access arguments' => array('access content'),
'page callback' => '_personal_rss_mkRSS', );
return $items;
}
//////////////////////////
function x_item()
{
$result = db_query("SELECT node.nid AS Nid, node.LANGUAGE AS \"Language\"\n" .
" , node . title AS Title, node_revisions . teaser AS Description,FROM_UNIXTIME(node.created,\"%a, %d %M %Y %h:%i:%s GTM\") AS pubdate\n" .
" FROM node INNER JOIN node_revisions ON node . nid = node_revisions . nid");
$data = db_fetch_array($result, MYSQL_BOTH);
return $data['pubdate'] . '<br/>' . $data['Language'] . '<br/>' . $data['Nid'] .
'<br/>' . $data[1]['Title'] . '<br/>' . $data['Description'] . '<br/>' . count($data) .
'<br/>otro';
}
/////////////////////////////////////////////////////////////
function _personal_rss_mkRSS() /**$nid,*/
{
$rss = array();
$url = 'http://localhost/drupal-6.20/node/';
$result = db_query('SELECT node.nid AS Nid, node.LANGUAGE AS "Language"
, node . title AS Title, node_revisions . teaser AS Description,FROM_UNIXTIME(node.created,"%a, %d %M %Y %h:%i:%s GTM") AS pubdate
FROM {node} INNER JOIN {node_revisions} ON node . nid = node_revisions . nid');
$data = db_fetch_array($result);
if (!$data) {
echo 'FATAL ERROR : DONT COULD CONNECT THE DB ';
} else {
/////////seccion 1 solo elemento////////////////
if (count($data) <= 0) {
$rss[] = ' <? xml version = "1.0" encoding = "utf-8" ?>';
$rss[] = '<rss version ="2.0">';
//seccion Channel
$rss[] = '<channel>';
$rss[] = sprintf('<title>%s</title>', 'RandomChannel1');
$rss[] = sprintf('<description>%s</description>', 'RandomDescription1');
$rss[] = sprintf('<language>%s-mx</language>', 'es');
$rss[] = sprintf('<link>%s</link>', $url . $data['Nid']);
//seccion Item
$rss[] = '<item>';
$rss[] = sprintf('<title>%s</title>', $data['Title']);
$rss[] = sprintf('<link>%s</link>', $url . $data['Nid']);
$rss[] = sprintf('<description>%s</description>', $data['Description']);
$rss[] = sprintf('<pubDate>%s</pubDate>', $data['pubdate']);
//end tags item,channel and rss
$rss[] = '</item>';
$rss[] = '</channel>';
$rss[] = '</rss>';
return _export('browser', $rss, '');
} else {
//para mas de un objeto
$lenght = count($data);
$rss[] = ' <?xml version = "1.0" encoding = "utf-8"?>';
$rss[] = '<rss version ="2.0">';
//seccion Channel
$rss[] = '<channel>';
$rss[] = sprintf('<title>%s</title>', 'RandomChannel2');
$rss[] = sprintf('<description>%s</description>', 'RandomDescription2');
$rss[] = sprintf('<language>%s-mx</language>', 'es');
$rss[] = sprintf('<link>%s</link>', 'http:localhost/drupal');
//seccion Item
//para futuras expansiones de esta funcion para mas items solo realiazar lo de la clase kml
$rss[] = '<item>';
$rss[] = sprintf('<title>%s</title>', $data['Title']);
$rss[] = sprintf('<link>%s</link>', $data['linkItem']);
$rss[] = sprintf('<description>%s</description>', $data['Description']);
$rss[] = sprintf('<pubDate>%s</pubDate>', 'Tue, 22 March 2011 01:30:35 GTM');
//end tags item,channel and rss
$rss[] = '</item>';
$rss[] = '</channel>';
$rss[] = '</rss>';
return _export('browser', $rss, '');
}
}
}
function _export($mode = 'browser', $xml = array(), $path_to_file)
{
switch ($mode) {
case 'download':
header("Content-type: text/xml");
header("Pragma: public");
header("Cache-control: private");
header("Expires: -1");
header("Content-Disposition: attachment; filename=rss.xml");
header("Content-Type: application/force-download");
exit($xml);
break;
case "write":
if (empty($path_to_file))
return "No file destination was given.";
if (!file_exists($path_to_file))
if (!touch($path_to_file))
return "Unable to create the file '$path_to_file'.";
if (!$file = fopen($path_to_file, "wb"))
return "Unable to open file '$path_to_file' for writing.";
if (!fwrite($file, $this->rss))
return "Unable to write contents to file '$path_to_file'.";
if (!fclose($file))
return "Unable to close the file '$path_to_file'.";
return true;
default:
header("Content-type: text/xml");
header("Pragma: public");
header("Cache-control: private");
header("Expires: -1");
$output = join($xml);
return $output;
}
}
?>
Ubicación: http://localhost/drupal-6.20/personal_rss/data
Número de línea 55, columna 14: <?xml version = "1.0" encoding = "utf-8"?><rss version ="2.0"><channel><title>RandomChannel2</title><description>RandomDescription2</description><language>es-mx</language><link>http:localhost/drupal</link><item><title>TEST2</title><link></link><description>Así como el primer juego de la serie de Parasite Eve ya llegó a la PlayStation Network, ahora tenemos noticias de que la segunda parte también arribará de manera digital al servicio.
-------------^