omeka-s
omeka-s copied to clipboard
Add partial template for HTML page blocks.
Currently, HTML blocks for pages have no template. Instead, the render function simply returns the contents of the block, optionally wrapping it in a <div>
if the user specifies any CSS classes:
// From file: /application/src/Site/BlockLayout/Html.php
public function render(PhpRenderer $view, SitePageBlockRepresentation $block)
{
$htmlBlock = $block->dataValue('html', '');
$divClass = $view->escapeHtml($block->dataValue('divclass'));
if (!empty($divClass)) {
//wrap HTML in div with specified class, if present
$htmlFinal = '<div class="' . $divClass . '">';
$htmlFinal .= $htmlBlock;
$htmlFinal .= '</div>';
} else {
$htmlFinal = $htmlBlock;
}
return $htmlFinal;
}
It would be better if HTML blocks used a partial template just like the others, such as the dead simple page title block:
// From file: /application/src/Site/BlockLayout/PageTitle.php
public function render(PhpRenderer $view, SitePageBlockRepresentation $block)
{
return $view->partial('common/block-layout/page-title', [
'pageTitle' => $block->page()->title(),
]);
}
If someone can confirm to me that all I need to do is...
- Adapt the HTML block's
render()
to the same logic as in the page title block, and - Move the logic for the
<div>
with classes into a new/application/view/common/block-layout/html.phtml
template
...then I can handle putting together a pull request.
That's the process, yeah. There's some in-progress work on another branch that may affect the "class" part of this block but we can deal with that.
We're still pending on your earlier PR also. Last I recall there were a few small unresolved issues.
Out of curiosity, what changes are you looking to make in themes to this, or other, blocks? I assume that's the impetus behind these requests.
4.1.0 converted all blocks to use partials including this one, as well as adding an explicit theme template system for alternative user-selected templates.