Problem: I’m creating a module and I’m trying to extract whatever the URI is that corresponds to an item’s title through code. So, in something like the item-with-metadata, you see code that just says “$item->displayValues():” but I want to get just the uri of the title, not anything else. I’ve found this code snippet from the file, Uri.php, which is ultimately what I need to use in my module, but of course it doesn’t work because I’m not including the correct files. For instance, I’ve tried including what is at the top of Uri.php, such as “use Omeka\Api\Adapter\AbstractEntityAdapter;
use Omeka\Api\Representation\ValueRepresentation; etc”, but without success.
If someone could steer me in the right direction as to what I’m doing wrong to get this to work, I would greatly appreciate it as I’ve spent a lot of time already. Thanks!
public function render(PhpRenderer $view, ValueRepresentation $value)
{
$uri = $value->uri();
$uriLabel = $value->value();
if (!$uriLabel) {
$uriLabel = $uri;
}
return $view->hyperlink($uriLabel, $uri, [‘class’ => ‘uri-value-link’]);
}
No, I’m not trying to get to the url of the item, I’m trying to find the uri of the item title (see screen shot). So right now, the thumbnail of the image is set to go to the item’s url, but I want to build a module that includes the ability to choose for the image to link to the uri, which is the url of the “view collection” link.