Search
Other Sourcerer questions
Forum

Sourcerer – JCE damaging code

Brandon Nelson's Avatar Brandon Nelson
Joomla 4.4.6
JCE Editor - Free - 2.9.39
Sourcerer - Pro - Latest

I've followed just about every set up guide and I still have JCE changing the code injected by Sourcerer. The goal is to inject javascript into the head and add some extra CSS for a few real estate properties on the site that we display using OSProperty for marketing tracking purposes. The occasions I did get it to work, the editor then damages the code if you make any additional changes to the article.

JCE Global Configuration
Validate HTML - NO
Entity Encoding UTF-8
Container Element & Enter Key - Paragraph:Paragraph
Compress Javascript - NO
Compress CSS - NO
Enforce Cache Validation - NO

JCE - Profiles - Default - Edit Parameters Advanced
Validate Styles - NO
Enable Code Blocks - Yes
Allow Javascript - Yes
Allow CSS - Yes
Allow PHP - Yes
Allow Custom XML - No
Peter van Westen's Avatar Peter van Westen ADMIN
You should ask the developers of JCE for help on that.

Also see:
docs4.regularlabs.com/sourcerer/faqs/tro...n-i-save-the-article
Please post a rating at the Joomla! Extensions Directory
Brandon Nelson's Avatar Brandon Nelson
The altered code is not from JCE, it is from Sourcerer. For visual purposes, Sourcerer adds tabs so the code formatting looks good. The tabs are placed as small lines of SVG code. All looks great and I click save. Code works. Once I open the same article again the tabs now show up as <img src="/media/sourcerer/images/tab.svg" />. If I make no edits to the code, but make a change to the article text and click save, the code will be broken. So for now, any edits to the article require me to reinsert my code.
Brandon Nelson's Avatar Brandon Nelson
Also, I tried disabling JCE for the component I am using and when I opened an article, it still displayed the same code with the inserted SVG files.
Peter van Westen's Avatar Peter van Westen ADMIN
The images should be there. It is for display purposes only in the editor itself. It should not affect the result on the frontend.

What do you mean with 'the code will be broken'? What breaks?
Do you have this online so I can take a look?
Please post a rating at the Joomla! Extensions Directory
Brandon Nelson's Avatar Brandon Nelson
When I first inject the code, everything works as it should. What happens is when you go to make edits to the article and save, then the Sourcerer injected code is broken. The client has apartment properties posted to their site. We need to inject marketing code onto 4 of the 33 properties. Below is a link to one of the properties.

celticpropertymanagement.com/osproperty/auburn-brook-39

On the first save, everything works as it should. If I go to edit the property, the code is no longer valid. All the code validation is shut off in JCE Pro.
Peter van Westen's Avatar Peter van Westen ADMIN
Can you give me (super) admin so I can take a look?
And tell me on what url I can see/reproduce the issue.
You can use the 'Confidential information' button in the forum editor to hide sensitive information.
Please post a rating at the Joomla! Extensions Directory
Brandon Nelson's Avatar Brandon Nelson
Confidential information:
(hidden)

Review this URL before you make changes:
celticpropertymanagement.com/osproperty/auburn-brook-39

You will notice Contact Us! and Book tour buttons. These will open a modal with a contact form. These are styled and triggered by Sourcerer injecting the JS into the header. I also inject a little CSS to hide elements that I don't want to display on these particular pages.

Then navigate to Components/Ossolution Property/Manage Properties/search for Auburn Brook. You can make any small change to the description, then click save. The code will no longer work. I just want the client to be able to edit those pages if they want.
Brandon Nelson's Avatar Brandon Nelson
Confidential information:
(hidden)

Both the JS and CSS are inserted before the HTML body.
Peter van Westen's Avatar Peter van Westen ADMIN
I cannot log in with that account.

But if you say that the code is ok on first save, and then is incorrect when going back to edit it, then this is not caused by Sourcerer.
The editor button just inserts content into the editor.
The editor is responsible for saving that.
The editor is responsible for displaying the saved content correctly in the editor on reopening the article.

If you place Sourcerer content into an article, but have protected the use of Sourcerer in the frontend (via the Sourcerer system plugin settings), or have set up the editor to not allow certain code on the frontend.
Then yes, editing those articles on the frontend will cause the issues you say.

If you want to use Sourcerer in articles, but don't want frontend visitors to be able to edit that, then you will have to solve this in a different way.
You could place the Sourcerer code in a custom field that is not editable on the frontend, but does get output.
Or place the Sourcerer code in a module, and assign that module to the pages where you want it to be active.
Please post a rating at the Joomla! Extensions Directory
Brandon Nelson's Avatar Brandon Nelson
Brilliant! The module solution was perfect. The osProperty component must be altering the code, because when I create a custom module and can easily update the component without the code being damaged. Your Modules Anywhere extension always works great and made this fix possible! Sorry, I should have figured this workaround on my own, but I am down to just the one Joomla site, all my other clients are on Wordpress and other platforms so I am out of practice. Thank you for your help on this one.
Peter van Westen's Avatar Peter van Westen ADMIN
Happpy you have it working.

PS: you could also use Snippets instead of modules…
regularlabs.com/snippets
Please post a rating at the Joomla! Extensions Directory
Brandon Nelson's Avatar Brandon Nelson
Thanks, I'll keep Snippets in mind as well.
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription