Issues with placement of Geolocation and Commenting plugins when Universal Viewer is moved to top of item page

I have followed the instructions from this previous thread (I would like to make three changes to the Item display page for the public: move the universalviewer above the metadata, break the metadata into two columns, and remove "Files" from the metadata) to move the Universal Viewer to the top of each item page by moving the code in the show.php file. When I do this, however, the Geolocation and Commenting plugins also populate at the top of the page (and not in a visually pleasing order, i.e. Viewer at top and commenting and geolocation at bottom).

I am assuming this is happening because all of these plugins are connected to this line of code “<?php fire_plugin_hook('public_items_show', array('view' => $this, 'item' => $item)); ?>”. Being inexperienced with PHP, I am not sure how to separate the locations for each of the plugins to have them placed where I would like on the page. Is there a way to separate and assign a different placement for each of these plugins when they show up on an item page? Hopefully that makes sense.

Thank you!

Melinda

To separate the output of several plugins that use the same hook, you can use the get_specific_plugin_hook_output function:

echo get_specific_plugin_hook_output('Geolocation', 'public_items_show', array('view' => $this, 'item' => $item));

You’ll need to account for all the plugins you want to show by calling that function several times, once with each plugin to display in the appropriate place. You’ll also want to remove or comment out the normal fire_plugin_hook call, otherwise you’ll get duplicate output.

Thank you so much for your quick reply! So being a PHP newbie and to clarify:

  1. I use my original line:
<?php fire_plugin_hook('public_items_show', array('view' => $this, 'item' => $item)); ?>
  1. Modifying and duplicating it for each plugin (like below), then placing it in the location in the show.php file where I want it to show up on the item page.

echo get_specific_plugin_hook_output(‘Geolocation’, ‘public_items_show’, array(‘item’ => $item, ‘view’ => $this)); ?>

echo get_specific_plugin_hook_output(‘Commenting’, ‘public_items_show’, array(‘item’ =>; $item, ‘view’ => $this)); ?>

echo get_specific_plugin_hook_output(‘Universal Viewer’, ‘public_items_show’, array(‘item’ => $item, ‘view’ => $this)); ?>

(Do I need to delete or add to any of these above lines?)

  1. Then I delete my original line to prevent duplicate output.

Did I understand that correctly?

Thank you!

-Melinda

The only little issue I’d mention is that the “plugin name” that needs to get passed is the internal name, which generally means no spaces or things like that, so “UniversalViewer” and not “Universal Viewer.” The name you need should be the same as the name of the plugin’s folder underneath “plugins/” on the server.

Thank you for getting back to me. So I have tried as you suggested, and have inserted the lines below into the locations where I would like the to populate on each item page:

echo get_specific_plugin_hook_output(‘Geolocation’, ‘public_items_show’, array(‘item’ => $item, ‘view’ => $this)); ?>

echo get_specific_plugin_hook_output(‘Commenting’, ‘public_items_show’, array(‘item’ => $item, ‘view’ => $this)); ?>

echo get_specific_plugin_hook_output(‘UniversalViewer’, ‘public_items_show’, array(‘item’ => $item, ‘view’ => $this)); ?>

When I do that, All that happens is the above lines show up on the item page, not the plugin itself. Any thoughts? Sorry to be such a newbie to all of this.

  • Melinda

Ah, this is just a problem where those lines are missing one little piece at the beginning: they should all start with <?php before the echo part.

Awesome! It worked. Thank you! Now the items are showing in the exact order I’d like. Perfect.

Any suggestions on why when I try to view an item from the admin side of my website I get this error?

Parse error : syntax error, unexpected ‘Viewer’ (T_STRING) in /home/melric17/arichhistory.com/admin/themes/default/items/show.php on line 24

It only started doing this after I made the changes suggested above. Is the “Viewer” in the error message referring to the Universal Viewer I am using?

Line 24 (from the section of the show.php file describing “tags”) reads:

<?php echo tag_string('item'); ?>

Hopefully the issue makes sense. Clearly, I have a lot to learn with PHP. Basically, everything. Haha.

  • Melinda

That error is probably caused by you editing the file admin/themes/default/items/show.php .

Is that the file you looked at (not the one in your public theme)?

haha. I thought I had only edited the file themes/default/items/show.php, not the one in the admin folder, but it looks like I must have. (No more sleep deprived work for me…) I fixed the error and now things are working perfectly!

Thank you so much for all of you’re help! I really appreciate it!

  • Melinda

This topic was automatically closed after 250 days. New replies are no longer allowed.