0

I am getting strange behavior while trying to add custom html via a custom html module. My markup is getting altered and the behavior is affected as a result. I want to have an anchor tag wrapped around an image, h2, and a p tag.

<div>
    <a href="#">
        <img src="/greentec-capital.com/images/gallery/bild4.jpg">
        <h1>Title</h1>
        <p>Some text here</p>
    </a>
</div>

Once saved, the anchor tag is only wrapped around the image, which makes the menu itself unusable.

<div>
    <a href="#">
        <img src="/greentec-capital.com/images/gallery/bild4.jpg">
    </a>
    <h1>Title</h1>
    <p>Some text here</p>
</div>

From, my research this is something to do with how the html is saved from the wysiwyg editor into the database.

So, something in the saving process is opinionated about how the html should be structured. Is there someway of preventing this? I've looked into the text filtering settings, and there doesn't seem to be an obvious fix from there. I'm relatively new to joomla, but it looks like the Code Mirror and TinyMCE editors are installed on the site.

Next, if there isn't an easy fix with an editor, would coding a module solve this problem?

  • Do you hard code your custom modules in pure HTML? Or use WYSIWYG editor for formatting text? – saibbyweb Nov 1 '16 at 15:01
  • I used whatever wysiwyg comes with the default custom HTML, I tried hard coded via custom module but that seemed easier... – nizz0k Nov 1 '16 at 17:54
  • A quick work around to stop your markup getting altered would be using 'Sourcerer' plugin. (Google it). After installing it, all you need is to wrap your code in {source} and {/source} tags, that's it. It will even allow you to include PHP and JS also. – saibbyweb Nov 1 '16 at 18:28
1

In your Joomla backend, go to Global Configuration >> Text Filters.

Under the Super User row, select No Filtering from the dropdown menu.

enter image description here

  • Hi @Lodder, that is the super user and admin user setting. From what I've read this has to do with how the wysiwyg formats the code before saving to the database... – nizz0k Nov 1 '16 at 9:38
1

So, I didn't find out the mechanics of why this happens, but it does. I solved my problem by using this the Custom HTML Advanced module, which doesn't do any text filtering at all. Another solution would have been to use a custom module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.