Plugin: add render_feed hook and call it while generating ATOM and RSS feed.
Create an example of the new hook in the demo plugin.
This commit is contained in:
parent
e67712ba0f
commit
bcd078bf0a
2 changed files with 32 additions and 1 deletions
|
@ -785,6 +785,12 @@ function showRSS($pageBuilder, $linkDB)
|
||||||
$data['usepermalinks'] = $usepermalinks;
|
$data['usepermalinks'] = $usepermalinks;
|
||||||
$data['links'] = $linkDisp;
|
$data['links'] = $linkDisp;
|
||||||
|
|
||||||
|
$pluginManager = PluginManager::getInstance();
|
||||||
|
$pluginManager->executeHooks('render_feed', $data, array(
|
||||||
|
'loggedin' => isLoggedIn(),
|
||||||
|
'target' => Router::$PAGE_RSS,
|
||||||
|
));
|
||||||
|
|
||||||
$pageBuilder->assignAll($data);
|
$pageBuilder->assignAll($data);
|
||||||
$pageBuilder->renderPage('feed.rss', false);
|
$pageBuilder->renderPage('feed.rss', false);
|
||||||
$cache->cache(ob_get_contents());
|
$cache->cache(ob_get_contents());
|
||||||
|
|
|
@ -323,3 +323,28 @@ function hook_demo_plugin_delete_link($data)
|
||||||
exit('You can not delete a YouTube link. Don\'t ask.');
|
exit('You can not delete a YouTube link. Don\'t ask.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute render_feed hook.
|
||||||
|
* Called with ATOM and RSS feed.
|
||||||
|
*
|
||||||
|
* Special data keys:
|
||||||
|
* - _PAGE_: current page
|
||||||
|
* - _LOGGEDIN_: true/false
|
||||||
|
*
|
||||||
|
* @param array $data data passed to plugin
|
||||||
|
*
|
||||||
|
* @return array altered $data.
|
||||||
|
*/
|
||||||
|
function hook_demo_plugin_render_feed($data)
|
||||||
|
{
|
||||||
|
foreach ($data['links'] as &$link) {
|
||||||
|
if ($data['_PAGE_'] == Router::$PAGE_FEED_ATOM) {
|
||||||
|
$link['description'] .= ' - ATOM Feed' ;
|
||||||
|
}
|
||||||
|
elseif ($data['_PAGE_'] == Router::$PAGE_FEED_RSS) {
|
||||||
|
$link['description'] .= ' - RSS Feed';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue