Loading...
 
Skip to main content

Allow for rss feeds to use description data instead of title data for items (a la Yahoo Weather)

Status
Closed
Subject
Allow for rss feeds to use description data instead of title data for items (a la Yahoo Weather)
Version
1.9.x
Category
  • Feature request
Feature
RSS
XML RPC
Templates (Smarty)
Modules
Resolution status
Fixed or Solved
Submitted by
kingpin2k
Rating
(0)
Description
Yahoo Weather (and, I assume other feeds) rss feed dumps neat html into the description field of the first item rather than the title. I've modified function.rss.php to accomodate this and allow users to continue to use the regular module creation interface. Basically, I added a new parameter "desc" such that if you use
Commit by lphuberdeau :: r42605 /trunk/templates/tiki-editpage.tpl: (link) [FIX] Wiki and plugin help works without this, avoid double inclusion, reduce memory footprint
the resulting output will use the description field instead of the title field. Skipped items will still be skipped.


Sorry, but I'm very new to Tikiwiki and may not conform to regular documentation standards...please correct me as neceesary.

Solution

<?php

//this script may only be included - so its better to die if called directly.
if $_SERVER%22SCRIPT_NAME%22,basename(FILE !== false) {
header("location: index.php");
exit;
}

/* inserts the content of an rss feed into a module */
function smarty_function_rss($params, &$smarty)
{
global $tikilib;
global $dbTiki;
global $rsslib;
include_once('lib/rss/rsslib.php');
extract($params);
// Param = zone
if$id {
$smarty->trigger_error("assign: missing id parameter");
return;
}
if$max {
$max = 99;
}
if$desc {
$desc = 0;
}


// skip="x,y" will not print Xth and Yth items
// useful to avoid default first items
if (!empty($skip) && preg_match('/^\d+(,\d+)*$/', $skip)) {
$skipped_items = explode(',', $skip);
$skip = array();
foreach ($skipped_items as $i) {
$skip$i = 1;
}
} else {
$skip = array();
}
$data = $rsslib->get_rss_module_content($id);
$items = $rsslib->parse_rss_data($data, $id);

if ($items0%22isTitle%22=="y") {
print '<a target="_blank" href="'.$items0%22link%22.'" class="linkmenu">'.$items0%22title%22.'</a>';
$items = array_slice ($items, 1);
}

print('<ul class="rsslist">');

for($i=0;$i<count($items) && $i<$max;$i++) {
if (!$skip$i+1) {
if($desc) {

if ($items$i%22description%22 <> '') print('<li class="rssitem"><a target="_blank" href="'.$items$i%22link%22.'" class="rsslink">'.$items$i%22description%22.'</a>');

if ($items$i%22pubDate%22 <> '') print(' <span class="rssdate">('.$items$i%22pubDate%22.')</span>');

print('</li>');

}
else {

if ($items$i%22title%22 <> '') print('<li class="rssitem"><a target="_blank" href="'.$items$i%22link%22.'" class="rsslink">'.$items$i%22title%22.'</a>');

if ($items$i%22pubDate%22 <> '') print(' <span class="rssdate">('.$items$i%22pubDate%22.')</span>');

print('</li>');

}
}
}

print('</ul>');

}

/* vim: set expandtab: */

?>

Importance
3
Priority
15
Demonstrate Bug on Tiki 19+
Demonstrate Bug (older Tiki versions)
Ticket ID
721
Created
Wednesday 17 May, 2006 15:34:37 UTC
by Unknown
LastModif
Sunday 18 June, 2017 23:01:14 UTC


Show PHP error messages