mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Fixed RSS example
This commit is contained in:
parent
b5b8cb25e0
commit
e2238245b9
@ -150,18 +150,19 @@ Put something like this code in mysite/code/Page.php inside class Page_Controlle
|
||||
:::php
|
||||
// Accepts an RSS feed URL and outputs a list of links from it
|
||||
public function RestfulLinks($url){
|
||||
$delicious = new RestfulService($url);
|
||||
|
||||
$conn = $delicious->connect();
|
||||
$result = $delicious->getValues($conn, "item");
|
||||
$service = new RestfulService($url);
|
||||
$request = $service->request();
|
||||
$body = $request->getBody();
|
||||
$items = $service->getValues($body,"channel","item");
|
||||
|
||||
$output = '';
|
||||
foreach ($result as $key => $value) {
|
||||
foreach($items as $item) {
|
||||
// Fix quote encoding
|
||||
$description = str_replace('"', '"', $value->description);
|
||||
$output .= '<li><a href="'.$value->link.'">'.$value->title.'</a><br />'.$description.'</li>';
|
||||
$description = str_replace('&quot;', '"', $item->description);
|
||||
$output .= "<li><a href=\"{$item->link}\">{$item->title}</a><br />{$description}</li>";
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Put something like this code in `themes/<your-theme>/templates/Layout/HomePage.ss`:
|
||||
@ -174,4 +175,4 @@ Put something like this code in `themes/<your-theme>/templates/Layout/HomePage.s
|
||||
|
||||
|
||||
## API Documentation
|
||||
`[api:RestfulService]`
|
||||
`[api:RestfulService]`
|
||||
|
Loading…
Reference in New Issue
Block a user