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