Skip to content

Commit

Permalink
Add media render layout
Browse files Browse the repository at this point in the history
  • Loading branch information
jimsafley committed Feb 18, 2022
1 parent af30dbf commit b951a29
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
5 changes: 3 additions & 2 deletions application/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,12 +539,13 @@
],
'resource_page_block_layouts' => [
'invokables' => [
'values' => Site\ResourcePageBlockLayout\Values::class,
'linkedResources' => Site\ResourcePageBlockLayout\LinkedResources::class,
'itemSets' => Site\ResourcePageBlockLayout\ItemSets::class,
'linkedResources' => Site\ResourcePageBlockLayout\LinkedResources::class,
'mediaEmbeds' => Site\ResourcePageBlockLayout\MediaEmbeds::class,
'mediaLinks' => Site\ResourcePageBlockLayout\MediaLinks::class,
'mediaRender' => Site\ResourcePageBlockLayout\MediaRender::class,
'sitePages' => Site\ResourcePageBlockLayout\SitePages::class,
'values' => Site\ResourcePageBlockLayout\Values::class,
],
],
'resource_page_blocks' => [
Expand Down
2 changes: 0 additions & 2 deletions application/src/Site/ResourcePageBlockLayout/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,11 @@ public function getResourcePageBlocks(Theme $theme)
'item_sets' => [
'main' => [
'values',
'linkedResources',
]
],
'media' => [
'main' => [
'values',
'linkedResources',
]
],
];
Expand Down
23 changes: 23 additions & 0 deletions application/src/Site/ResourcePageBlockLayout/MediaRender.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
namespace Omeka\Site\ResourcePageBlockLayout;

use Omeka\Api\Representation\AbstractResourceEntityRepresentation;
use Laminas\View\Renderer\PhpRenderer;

class MediaRender implements ResourcePageBlockLayoutInterface
{
public function getLabel() : string
{
return 'Media render'; // @translate
}

public function getCompatibleResourceNames() : array
{
return ['media'];
}

public function render(PhpRenderer $view, AbstractResourceEntityRepresentation $resource) : string
{
return $view->partial('common/resource-page-block-layout/media-render', ['resource' => $resource]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php echo $resource->render(); ?>
3 changes: 1 addition & 2 deletions application/view/omeka/site/media/show.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ $this->htmlElement('body')->appendAttribute('class', 'media resource show'); ?>
<p class="media-parent-item">
<?php echo sprintf($translate('Part of %s'), $item->link($item->displayTitle())); ?>
</p>
<?php echo $media->render(); ?>
<?php echo $media->displayValues(); ?>
<?php echo $this->resourcePageBlocks($media)->main(); ?>
<?php $this->trigger('view.show.after'); ?>

0 comments on commit b951a29

Please sign in to comment.