Jump to content

Prevent FormBuilderMultiplier to inject script tags in my MJML export


Recommended Posts

Posted

Hi there,

So I used the plugin FormBuilderMultiplier by @BitPoet. The module has been working great but I run into an issue:

It injects the line <script type="text/javascript" src="/godzillab-stripe/site/modules/FormBuilderMultiplier/FormBuilderMultiplier.js"></script></head>

..on every page. That means it also appears inside my MJML export and breaks the MJML.

In the PageMjmlToHtml i made sure to not include anything automatically, but it gets included anyway. Not sure if mr BitPoet is around, if not, then I'm wondering what the workaround (if any) might be?

many thanks,

J

Posted

Yes, Mr. BitPoet is around ? Glad to hear you like my module. As a quick & dirty workaround, you could insert a short check for your PageMjmlToHtml template/page in the addScripts function in FormBuilderMultiplier.module after $page is assigned:

// If you want to prevent inclusion of the script for all pages with a certain template
if($page->template->name === "PageMjmlToHmtl") return;
// Or for a certain page id
if($page->id === 19389) return;

It makes sense to avoid including the script in every page that is rendered. I'm going to add a more selective mechanism there.

Posted
3 hours ago, joe_g said:

In the PageMjmlToHtml i made sure to not include anything automatically, but it gets included anyway. Not sure if mr BitPoet is around, if not, then I'm wondering what the workaround (if any) might be?

I'm assuming that PageMjmlToHml is a template, right? In that case, you can try the latest dev release 0.0.11. It has an option to exclude certain templates from script tag injection in the module settings.

fbm_excludetemplates.png.a019eadfb94d70fdcfbfb9dbe2dd7eae.png

  • 4 weeks later...
Posted
8 hours ago, joe_g said:

Tried it now and it works beautifully! Thank you for this update!!

Glad to hear, thanks for the feedback! I have pushed the change to the main branch.

Posted

Hey!

PageMjmlToHtml author here ?

@BitPoet wouldn't it be best if instead of having to opt-out templates the js script was only added when the multiplier fields are added? Not tested but maybe you could put the Page::render hook inside of addMultipliedFieldsToProcessor?

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...