Jump to content

Scripts in CMS content doesn't save (1.7.6.8)


zenotods

Recommended Posts

I need to put a script in the content field of a CMS page.

On a previous project i simply overrode the Validate and CMS controller to allow scripts and skip validation but on 1.7.6.8 even doing so doesn't work.

Any suggestion? Would love to make it work with core controllers instead of injecting the content via DB or putting conditional codes in the template.

Link to comment
Share on other sites

Probably like this.
If you find how Prestashop stores content in the database, you will find that it uses the pSQL function, which removes invalid parts from the text according to the settings in the administration and the enabled cleanHTML function.
If you have cleanHTML enabled and you do not have javascript wrapped in literal, it will be removed when saving, etc ...

Link to comment
Share on other sites

The thing is no matter what i do in the ovverride it never parses as valid, even by wrapping it in {literal}..

The function

class Validate extends ValidateCore
{
function isCleanHtml($html)
{
return true;
}
}

should make ANYTHING in the content field to go through.. but it seems overrides are totally ignored...
For now i just inserted the content via DB but i guess something has changed from 1.7.5 to 1.7.6 and now overrides are deprecated to a certain degree...

Same with the CMS class and AdminCmsController... i edited them with the intention of getting a new custom field in the CMS folder and updated the db structure to include the new field.. the field doesn't show up in the editing form, cms page doesnt save and throws an error, but i get the value of the db cell in the smarty debugger.

Link to comment
Share on other sites

Yes, from 1.7.6 everything is wrong.
From. In this version, developers learn composer.
I received information that the old team only uses shovels and pickaxes and that a new team has joined to fix everything. Unfortunately, I have to tell you that without your own module you can't insert your own js in the text box.

Link to comment
Share on other sites

Yeah. I joined the PS slack and apparently the only way to override the new symfony framework is with custom modules... that's bad...
Guess i'll just inject stuff with db and work with conditional TPL.. i have zero skills with composer, symfony etc.. i'm just a frontend dev..

Edited by zenotods (see edit history)
Link to comment
Share on other sites

I understand, unfortunately, this is the only sensible solution now.
It is similar for other controllers. There is no possibility to rewrite multiple times.
Ie. if one module overwrites a twig, another is unlucky. It will either overwrite an already overwritten one or get an error.
Long live the closed open source.
It is no longer open software, Prestashop should quickly change the license.

Link to comment
Share on other sites

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
×
×
  • Create New...