Replacing HTML for Markdown

Hi,

We have a bit of a problem with the HTML block. Our graphic design team does not want different font sizes and colours on the website, but formatted text pasted into the textarea is rendered. Is there an easy solution to this?

To get around the issue, we’ve made a small Markdown module that works fine. I’m now trying to remove the option to include the HTML block in pages. So far I have a work around that works.

        'template_map' => [
           'omeka/site-admin/page/edit' => __DIR__ . '/../../../themes/my_theme/view/omeka/site-admin/page/edit.phtml',
         ],

Copy ./application/view/omeka/site-admin/page/edit.phtml into my_theme directory

Then edit.

    <?php foreach ($this->blockLayout()->getLayouts() as $layout): ?>
add -->    <?php if ($layout == "html") { continue; } ?>
    <button type="button" value="<?php echo $escape($layout); ?>" class="option">
        <?php echo $escape($translate($this->blockLayout()->getLayoutLabel($layout))); ?>
    </button>
    <?php endforeach; ?>

But this isn’t going to help at all when it comes time to upgrade Omeka.

Any suggestions?

Thanks.

You could use your module to just deregister the HTML block so it’s not available anywhere.

You could also probably just make your module’s Markdown block replace the HTML block by giving it the same internal “name” as the existing HTML block when you’re registering it in your module’s config file.

Both of these options will have problems if you have existing pages using the HTML block but should be fine if it’s never used at all.

Hi,

I can successfully deregister blocks as you suggested

if (isset($config['block_layouts']['invokables']['tableOfContents'])) {
  unset($config['block_layouts']['invokables']['tableOfContents']);
}
if (isset($config['block_layouts']['invokables']['browsePreview'])) {
  unset($config['block_layouts']['invokables']['browsePreview']);
}

Thanks!

I see the html block is included as a factory, and if I do …

if (isset($config['block_layouts']['factories']['html'])) {
  unset($config['block_layouts']['factories']['html']);
}

…the block is not removed but made invalid

Unknown [html]
This layout is invalid.

Does that mean that I can only remove blocks that are invokable?
What about other blocks like searchingForm? I cannot find it either as a invokable or a factory.

Thanks again.

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