Printing out Item Identifier on Item Browse Details Page

34 views
Skip to first unread message

Adina Langer

unread,
Mar 14, 2013, 10:38:13 AM3/14/13
to omek...@googlegroups.com
Hello team Omeka developers.

I am trying to write a simple plugin that will add a line to the details view for item browse results with "ID: (the item id from Dublin Core)" I have attempted to use the item id helper function to call up the item ID and print it.  However, I get the following error message. "Notice: Undefined variable: id in /var/www/omeka/plugins/IdentifierAddOn/IdentifierAddOnPlugin.php on line 28 ID:"

Basically, I need to figure out how to define the id variable properly. You can see from the commented line 27 that I had attempted to use the language from the id helper to define my id variable, but that threw a fatal error...  Below is how my code looks now. Thanks for any advice.

`
<?php
/**
 * IdentifierAddOn * 
 * @copyright Copyright 2013 Adina Langer
 */

/**
 * IdentifierAddOn Plugin.
 * @package Omeka\Plugins\IdentifierAddOn
 * 
 {*/
class IdentifierAddOnPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_hooks = array(
'admin_items_browse_detailed_each',
);

    /**
     * Prints out the Identifier on the admin browse results details  page.
     */
    
    public function hookAdminItemsBrowseDetailedEach($args)
{
   $item = $args['item'];
   // $id  = dig up the identifier
// $id = $item('ID');
   echo "ID: $id";
}
}
`


Jeremy Boggs

unread,
Mar 14, 2013, 10:50:28 AM3/14/13
to omek...@googlegroups.com
Should probably just have to replace $id = $item('ID') with $id = $item->id or $id = metadata($item, 'ID') in your hookAdminItemsBrowseDetailedEach method. Your $id isn't getting defined because $item() isn't the right syntax.

Jeremy
> --
> You received this message because you are subscribed to the Google Groups "Omeka Dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to omeka-dev+...@googlegroups.com.
> To post to this group, send email to omek...@googlegroups.com.
> Visit this group at http://groups.google.com/group/omeka-dev?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Adina Langer

unread,
Mar 14, 2013, 11:03:05 AM3/14/13
to omek...@googlegroups.com
Thanks, Jeremy!  That's great.  Only catch is that I actually want the Dublin Core "identifier" value. Do you know where I can find the shorthand for this? "identifier" doesn't seem to be correct. 

Patrick Murray-John

unread,
Mar 14, 2013, 11:12:42 AM3/14/13
to omek...@googlegroups.com
For that, use $id = metadata($item, array('Dublin Core', 'Identifier'));

Basic pattern of metadata() is for the second parameter to be either the string for the property on the record (like the record's id), or an array for the element set and element as above.

Adina Langer

unread,
Mar 14, 2013, 11:19:41 AM3/14/13
to omek...@googlegroups.com
It works!  Thanks a bunch.
Reply all
Reply to author
Forward
0 new messages