Use Loadposition to Prevent Code Stripping in Joomla

Use Loadposition to Prevent Code Stripping in Joomla

There’s nothing more frustrating than going into an article to make a small change and then when you save it, you find that some code that was in the article has stripped.

Here’s a great way to get around that by using the {loadposition} plugin to prevent code stripping in Joomla.

What we’re going to do is set up a custom HTML module with the code and then load it through the article. That way, people can edit the article with the editor on and not worry about the code stripping.

Let’s get started.

Let’s say you have some embed code from an external form provider, a PayPal button, a newsletter sign-up box, or perhaps a chat engine that you want to use in an article with text before and after the form. You get it all set up, and then you Save it and go refresh on the frontend and the embed code is gone. It’s stripped. You’ve tried everything with settings in your editor, but nothing is working. I’ve got you.

  • login to the backend of Joomla.

Then, we’ll verify that the plugin Content – Load Modules is enabled.

  • go to Extensions -> Plugins
  • enter Load Modules into the search bar
  • press enter
  • enable the module if it isn’t already enabled
  • click Save & Close if any change was made. (If not, simply click Close.)

Use Loadposition to Prevent Code Stripping in Joomla

Use Loadposition to Prevent Code Stripping in Joomla

Use Loadposition to Prevent Code Stripping in Joomla

  • go to Users -> Manage

Use Loadposition to Prevent Code Stripping in Joomla

  • search for your Username
  • click on it

In the Basic Settings tab, locate the field for Editor. (Make note of the existing editor’s name so you can change it back later.)

  • select Editor – None from the drop-down

Use Loadposition to Prevent Code Stripping in Joomla

  • click Save & Close in the Top Toolbar
  • copy your embed code
  • go to Extensions -> Modules

Use Loadposition to Prevent Code Stripping in Joomla

  • click on the New button in the Top Toolbar
  • select Custom from the list of Module types

Use Loadposition to Prevent Code Stripping in Joomla

  • enter the Title
  • paste the embed code you just copied into the empty and void of editor content area.
  • toggle if you want the Title to Show or Hide
  • type any unique name/word into the Position field (In our case, it’s a donation form, so I’m going to name the position donationform)

NOTE: This position name must be unique and not in use anywhere else on the site.

  • press enter on my keyboard
  • type in the Note field, in ALL CAPS that the code will strip and to turn off editor before entering

This note appears in the Module list, so that it alerts you and others that action is needed before entering the module.

Use Loadposition to Prevent Code Stripping in Joomla

In the Menu Assignment tab, confirm that the module is set to display on ALL PAGES. This is very important.

Use Loadposition to Prevent Code Stripping in Joomla

  • click Save & Close

You can see how the Note displays on the Module list view.

Use Loadposition to Prevent Code Stripping in Joomla

Now, it’s time to work on the article.

  • go back to Users -> Manage
  • turn on your editor by repeating the same steps we used to turn it off
  • click Save & Close
  • go to Content -> Articles -> Add New Article
  • add a title to your article (The alias will fill in automatically)
  • select a Category for your article (We’re going to select the Blog category.)
  • add the content you want for your article in the Content area

When you get to the place in the article that you want your form to load, type {loadposition donationform} into the article.

This will load the module you created inside the article. The beauty is that because there is no code embedded in the article, you can edit the article freely with the editor on without stripping the code.

Use Loadposition to Prevent Code Stripping in Joomla

When complete, view your article on the frontend (add a Menu Item if needed) and confirm that it works.

If it’s a form, test the form itself. If it’s a PayPal button, test it. Test. Always test.

Use Loadposition to Prevent Code Stripping in Joomla

That’s it! Well done.

For more terrific tutorials and trainings about Joomla, subscribe and gain acces to all of our books and video courses.

Author

  • Jennifer Gress

    Jenn has worked with Joomla since 2006 and for clients since 2010. She co-organised the JUG Bay Area for many years and volunteers for the Joomla! Project regularly. Originally from Santa Cruz, CA, she now lives near Austin, TX.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x