kevinjardine/shoutout — Issue #14: Make elgg-river-timestamp have a link to the shoutout item page
Author: mrclay
Created: 2012-01-27 16:40:25+00:00
State: open

(just a suggestion we've already implemented on our side)

We applied a plugin hook handler for "view", "river/elements/body" with this code inside the handler:

```
if (isset($params['vars']['item'])) {
$item = $params['vars']['item'];
if ($item instanceof ElggRiverItem) {
/* @var ElggRiverItem $item */
$entity = $item->getObjectEntity();
if (elgg_instanceof($entity, 'object', 'shoutout')) {
$url = $entity->getURL();
$returnValue = preg_replace_callback(
'@()([^/]+)()@',
function ($m) use ($url) {
$link = elgg_view('output/url', array(
'href' => $url,
'text' => $m[2],
));
return $m[1] . $link . $m[3];
},
$returnValue);
}
}
}
```

This uses an anonymous function, but you can pull that out to a global function for 5.2 compat.