Add a link to modify the current item

I would like to add a link to modify the current item.

This link should be display to the public show page only if the user is connected. Idealy, it should be in the top bar.

With Omeka Classic something like that worked:

  $user = current_user();
  if(isset($user)): ?>
	  <a href="<?php echo url('/admin/items/edit/'.metadata('item', 'id'));?>">modify the current item</a>
  <?php endif; ?>

What is the equivalent for S?

The user bar is done for that and there was a pull request some months ago for such a feature.

Outside of the user-bar, where $resource or $resources is not available, but in common show.phtml templates:

$translate = $this->plugin('translate');
$user = $this->identity();
if ($user): ?>
        <a href="<?php echo $resource->adminUrl('edit'); ?>">modify the current item</a>
<?php endif; ?>

There is no default label for resource currently.
No so different from Omeka Classic, as usual.

To manage escaping (security) automatically, you can even use:

<?php echo $this->hyperlink(sprintf($translate('Edit %s'), $resource->getControllerName()), $resource->adminUrl('edit')); ?>

Works perfectly in the meantime (I hope the top bar modification will be integrated to the next release) !


I am now looking for a piece of code which allows to modify the (html) media attached to a item directly from this item.

This is tricky because the media does not have the same ID than the item.

From item 1 I want to access media with id 2 (/admin/media/2/edit#media). If item 1 has several media attached, I want the first one (or the one with “xxx” in the title").

Any idea? Maybe there is a module for that (that I didn’t find)

I opened a specific topic for this issue.