Insert javascript in a page

General questions about CMSimple
doczimut
Posts: 126
Joined: Thu Dec 25, 2008 1:10 pm
Location: Normandy (France)

Insert javascript in a page

Post by doczimut » Thu Nov 12, 2020 12:02 pm

Hello
I want to insert a script (Tripadvisor) in a page, only this one is not taken into account by the editor. I looked at the forum, but I didn't really find a solution, except #extended_valid_elements: 'script [language | type | src]' # in one of the files of Tinymce4 (Cmsimple_XH 1.74), but which one ?

Code: Select all

<script src="https://www.jscache.com/wejs?wtype=selfserveprop&amp;uniq=880&amp;locationId=5966297&amp;lang=fr&amp;rating=true&amp;nreviews=5&amp;writereviewlink=true&amp;popIdx=false&amp;iswide=false&amp;border=false&amp;display_version=2"></script>

doczimut
Posts: 126
Joined: Thu Dec 25, 2008 1:10 pm
Location: Normandy (France)

Re: Insert javascript in a page

Post by doczimut » Thu Nov 12, 2020 2:51 pm

By reading the documentation of Tinymce4, I saw for the insertion of the javascript code it is necessary
To allow script elements in the editor, include the following in the TinyMCE configuration: extended_valid_elements : 'script[src|async|defer|type|charset]'
In the configuration of Tinymce4, the file [plugins/tinymce4/inits/init_fontawesome.js] is loaded, so I added the code:

Code: Select all

extended_valid_elements : 'script[src|async|defer|type|charset],span[*]'
My javascript is now taken into account. I hope I have done well!

---

This also works:

Code: Select all

extended_valid_elements: 'script[src],span[*]'

lck
Posts: 2963
Joined: Wed Mar 23, 2011 11:43 am
Contact:

Re: Insert javascript in a page

Post by lck » Thu Nov 12, 2020 5:52 pm

doczimut wrote:
Thu Nov 12, 2020 2:51 pm
This also works:

Code: Select all

extended_valid_elements: 'script[src],span[*]'
You can also use script[*] instead of script[src]. This should cover everything. See also here.
„Bevor du den Pfeil der Wahrheit abschießt, tauche die Spitze in Honig!“   👉 Ludwig's XH-Templates for MultiPage & OnePage

bastingse
Posts: 308
Joined: Fri Jun 06, 2008 9:38 pm
Location: Netherlands
Contact:

Re: Insert javascript in a page

Post by bastingse » Wed Sep 29, 2021 2:28 pm

i wonder if somebody have a simple solution alreeady to insert java script into a page. I want to add something like this:

Code: Select all

<link href="/1632923145_813/core/framework/libs/pj/css/pj.bootstrap.min.css" type="text/css" rel="stylesheet" />
<link href="/1632923145_813/index.php?controller=pjFront&action=pjActionLoadCss&id=10" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="/1632923145_813/index.php?controller=pjFront&action=pjActionLoadJS"></script>
<script type="text/javascript" src="/1632923145_813/index.php?controller=pjFront&action=pjActionLoad&id=10"></script>
Wonder if this can be done in a simple way into the standard cmsimple 1.7.4.
Any help is much much appreciated!

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Insert javascript in a page

Post by cmb » Wed Sep 29, 2021 3:15 pm

bastingse wrote:
Wed Sep 29, 2021 2:28 pm
i wonder if somebody have a simple solution alreeady to insert java script into a page. I want to add something like this:
I suggest to add a function to =userfuncs]cmsimple/userfuncs.php:

Code: Select all

<?php

function myJs() {
    global $hjs;

    $hjs .= '<link href="/1632923145_813/core/framework/libs/pj/css/pj.bootstrap.min.css" type="text/css" rel="stylesheet" />'
        . '<link href="/1632923145_813/index.php?controller=pjFront&action=pjActionLoadCss&id=10" type="text/css" rel="stylesheet" />'
        . '<script type="text/javascript" src="/1632923145_813/index.php?controller=pjFront&action=pjActionLoadJS"></script>'
        . '<script type="text/javascript" src="/1632923145_813/index.php?controller=pjFront&action=pjActionLoad&id=10"></script>';
}
Then on the page:

Code: Select all

{{{myJs}}}
Christoph M. Becker – Plugins for CMSimple_XH

bastingse
Posts: 308
Joined: Fri Jun 06, 2008 9:38 pm
Location: Netherlands
Contact:

Re: Insert javascript in a page

Post by bastingse » Wed Sep 29, 2021 3:22 pm

whow, if that works, that would be cool!!
Gonna try that later, thanks a lot !!!

bastingse
Posts: 308
Joined: Fri Jun 06, 2008 9:38 pm
Location: Netherlands
Contact:

Re: Insert javascript in a page

Post by bastingse » Fri Oct 08, 2021 10:50 am

Hi Christoph, i did create a userfuncs and added the code..... it does work but..... the result is not showing in the content but in the top of the page. https://kreutzerindemorgen.nl/?test

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Insert javascript in a page

Post by cmb » Fri Oct 08, 2021 8:53 pm

Hmm, what are the instructions to include that in an HTML page? Is there an option to place the output in a pre-defined element?
Christoph M. Becker – Plugins for CMSimple_XH

olape
Posts: 2731
Joined: Fri Mar 13, 2015 8:47 am
Contact:

Re: Insert javascript in a page

Post by olape » Sat Oct 09, 2021 7:51 am

It will probably be because $hjs is already through at this point.

Maybe better $bjs?
Gruß Olaf, Plugins for CMSimple_XH

Ich habe schon lange den Verdacht, dass so viele so eifrig auf Gender, Trans und Queer machen:
Weil sie für das Fachliche ganz einfach zu doof sind.

bastingse
Posts: 308
Joined: Fri Jun 06, 2008 9:38 pm
Location: Netherlands
Contact:

Re: Insert javascript in a page

Post by bastingse » Sat Oct 09, 2021 8:10 am

IT says to paste the code in the text where i want to show it.
What do you mean with pre-defined element??

Post Reply