How to embed html in static pages plugin

How do I embed HTML in the static pages plugin? I have tried using the HTML editor but it a) seems to not run the code and b) seems to not want to remember the code entered in the HTML dialog box. Text added works just fine. Am I missing some header? I can’t seem to find supporting documentation to help. Thanks!

Hi @radjr,

What version of OJS are you working with?

Regards,
Alec Smecher
Public Knowledge Project Team

Alec, 2.4.7.1 Thanks.

Trying to embed this code into that page to call a list of archived constant contact emails.

#archiveList > ul { list-style-type: circle; list-style-position: inside; }

Hi @radjr,

What kind of code are you trying to embed?

The problem is likely that we use an HTML filter (called HTML Purifier) to make sure that user-entered HTML doesn’t cause security risks. It’s configured to filter out suspect code such as Javascript etc.

You can see what kind of code is permitted by looking at the allowed_html setting in config.inc.php.

Regards,
Alec Smecher
Public Knowledge Project Team

The code is in my previous response above. But it does not want to display it in the forum.
It is javascript. I can share under PM if needed.

Too bad that Javascript is not allowed. And. a bunch of other html. Maybe this list is dated in config.inc.php?

Hi @radjr,

Generally speaking, it’s not safe to add Javascript to the list of allowed HTML – it can easily be abused to allow hackers to take control of the site. Your best bet for adding this safely might be to use a mechanism that can’t be created through the web interface, such as a template modification or custom plugin.

Regards,
Alec Smecher
Public Knowledge Project Team

Understood, but this is hard coded js going to a known site (constant contact) to display archived email blasts. There is not other html to support this functionality. (Thanks constant contact.)

Richard A. DeVito Jr.
Publisher
Weston Medical Publishing, LLC, 470 Boston Post Road, Suite 301, Weston, MA 02493 USA
radjr@pnpco.com - 781-899-2702 ext. 107 - 781-899-4900 fax
Join us at the 2016 International Conference on Opioids, June 5-7, 2016

Hi @radjr,

Reviewing this again, it looks like the Static Pages plugin (being a journal manager-only tool) doesn’t run supplied HTML through the HTML purifier, so it should be possible to embed Javascript in static pages – so it’s possible that TinyMCE is filtering out the javascript. You may need to edit your TinyMCE configuration to specifically permit this; see this StackOverflow thread.

Regards,
Alec Smecher
Public Knowledge Project Team

Thanks Alec. Yes, something is filtering it on save…I will look at that thread. Thanks again! Cheers!

Richard A. DeVito Jr.
Publisher
Weston Medical Publishing, LLC, 470 Boston Post Road, Suite 301, Weston, MA 02493 USA
radjr@pnpco.com - 781-899-2702 ext. 107 - 781-899-4900 fax
Join us at the 2016 International Conference on Opioids, June 5-7, 2016

Thanks Alec. That link has limited info…this link is better: Allow script and iframe tags in TinyMCE editor | Learn Web Design Online

Cheers!

Richard A. DeVito Jr.
Publisher
Weston Medical Publishing, LLC, 470 Boston Post Road, Suite 301, Weston, MA 02493 USA
radjr@pnpco.com - 781-899-2702 ext. 107 - 781-899-4900 fax
Join us at the 2016 International Conference on Opioids, June 5-7, 2016

1 Like

The one question is where do you hide the tinymce editor on OJS and where is the tinymce config file? cheers!

Richard A. DeVito Jr.
Publisher
Weston Medical Publishing, LLC, 470 Boston Post Road, Suite 301, Weston, MA 02493 USA
radjr@pnpco.com - 781-899-2702 ext. 107 - 781-899-4900 fax
Join us at the 2016 International Conference on Opioids, June 5-7, 2016

Hi @radjr,

I think what you’re looking for is in plugins/generic/staticPages/StaticPagesEditForm.inc.php.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi Alec, hope you are well.
I am still having troubles trying to embed Javascript into static pages via the HTML option.

I am not sure what changes to make to the “extended_valid_elements” below. Could you suggest what changes I need to get Javascript to be saved by tinymce and not stripped out? Thanks! Rich DeVito

"extended_valid_elements : “a[class|name|href|target|title|onclick|rel],script[type|src],iframe[src|style|width|height|scrolling|marginwidth|marginheight|frameborder],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],$elements”,