Add a link to modify the current item


#1

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:

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

What is the equivalent for S?


#2

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:

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

#3

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

Thanks!


#4

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)