omeka-s icon indicating copy to clipboard operation
omeka-s copied to clipboard

Add partial template for HTML page blocks.

Open DanielFlaum opened this issue 1 year ago • 1 comments

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...

  1. Adapt the HTML block's render() to the same logic as in the page title block, and
  2. 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.

DanielFlaum avatar Jun 24 '23 19:06 DanielFlaum

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.

zerocrates avatar Jun 26 '23 18:06 zerocrates

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.

zerocrates avatar Jun 10 '24 18:06 zerocrates