arpana
12-20-2007, 05:43 PM
Hi all,
I am using the songs.php plugin but would like to ammend how the song information is output. As it stands it just outputs in a continuous line, I would like to make it output as an unordered list.
I have virtually no PHP experience although I have (somehow) managed to work out where the <ul></ul> goes but unsure how to add the <li></li>, can anyone offer any guidance please?
Here is the code:
// Try to load and parse RSS file
// http://www.techie-blog.com/rss.php?blogId=1&profile=rss090
// http://ws.audioscrobbler.com/rss/recent.php?user=name_here
if ($rs = $rss->Get('http://ws.audioscrobbler.com/rss/recent.php?user=name_here', 10)) {
// Show last published articles (title, link, description)
$ctr = 1;
foreach($rs['items'] as $item) {
// formatting
$html .= "$ctr) ";
$html .= $item['title'];
// formatting
$html .= " // ";
$ctr++;
}
// strip the last slashes
$html = ereg_replace("// $", "", $html);
if (!$html) $html = "Sorry - I've not got any recently played songs - come back soon.";
$tpl = ereg_replace("<MY_SONGS>","<ul class=\"pp-songs\">\n".$html."</ul>\n",$tpl);
}
else {
$tpl = ereg_replace("<MY_SONGS>","Sorry - either I've not listened to any songs recently, or there's trouble collecting the feed of songs over the Net, either way, there's nought to be seen here.\n",$tpl);
}
Thanks
Arpi
I am using the songs.php plugin but would like to ammend how the song information is output. As it stands it just outputs in a continuous line, I would like to make it output as an unordered list.
I have virtually no PHP experience although I have (somehow) managed to work out where the <ul></ul> goes but unsure how to add the <li></li>, can anyone offer any guidance please?
Here is the code:
// Try to load and parse RSS file
// http://www.techie-blog.com/rss.php?blogId=1&profile=rss090
// http://ws.audioscrobbler.com/rss/recent.php?user=name_here
if ($rs = $rss->Get('http://ws.audioscrobbler.com/rss/recent.php?user=name_here', 10)) {
// Show last published articles (title, link, description)
$ctr = 1;
foreach($rs['items'] as $item) {
// formatting
$html .= "$ctr) ";
$html .= $item['title'];
// formatting
$html .= " // ";
$ctr++;
}
// strip the last slashes
$html = ereg_replace("// $", "", $html);
if (!$html) $html = "Sorry - I've not got any recently played songs - come back soon.";
$tpl = ereg_replace("<MY_SONGS>","<ul class=\"pp-songs\">\n".$html."</ul>\n",$tpl);
}
else {
$tpl = ereg_replace("<MY_SONGS>","Sorry - either I've not listened to any songs recently, or there's trouble collecting the feed of songs over the Net, either way, there's nought to be seen here.\n",$tpl);
}
Thanks
Arpi