Posts by: juergen

Posts: 1384
Post: 11000
Topic: Javascript in plugins

…and add sth. like

console.log('fa5free.js was loaded');

to the end of fa5free.js

1 year ago
Post: 10999
Topic: Javascript in plugins

… that alert(ck_base) lets the editor hang.

better try

var ck_base_is = typeof(ck_base) == 'undefined' ? 'undefined' : ck_base;
console.log("ck_base = " + ck_base_is);

and watch the browser's JS console

1 year ago
Post: 10997
Topic: Javascript in plugins

It would be an enhancement to be easy able to add a userspecific field to the 'Content Type'

We have filter hooks (Section Types, NewSections, GetDefaultContent) for that too – unfortunately the array structure to define custom section combos is rather awkward.
You can look up SliderFactory's code to see them in action.

1 year ago
Post: 10996
Topic: Javascript in plugins

The $type parameter of the InlineEdit_Scripts hook function call is used as a filter to only modify the $scripts array for specific section types, so the 'early exit' condition…

if( $type !== 'text' ){
    return $scripts;

will exit the function call by returning the unaltered $scripts array for every section that's not of the 'text' (= "Editable Text") type.

Edited: 1 year ago
Post: 10994
Topic: Javascript in plugins

I'm not sure if are we talking abot a Typesetter plugin or a pure CKEditor plugin?

$addonRelativeCode only applies to Typesetter plugins (installed via Admin Toolbox->Plugiins->Manage). Those may also contain CKeditor plugins.

Pure CKeditor plugins (installed via Admin Toolbox->Settings->CKeditor) will go to /data/_ckeditor/[plugin_folder] and neither have PHP backends nor PHP variables.

1 year ago
Post: 10992
Topic: Javascript in plugins
var JSONItems = [];
$.getJSON( "fa/fa5free.json", function( data){
  JSONItems = data;

Most likely an incorrect path. You will have to prepend the $addonRelativeCode value here…

GetHead hook:

$page->head_script .= "\n" . 'var fa5_addon_base = "' . $addonRelativeCode . '";' . "\n";


InlineEdit_Scripts hook:

$scripts['code'] = 'var fa5_addon_base = "' . $addonRelativeCode . '";';

then in JS try

var JSONItems = [];
$.getJSON( fa5_addon_base + "/fa/fa5free.json", function(data){
  JSONItems = data;
Edited: 1 year ago
Post: 10988
Topic: Javascript in plugins

i want to load a .json file into a js-array and got with jquery the error of unexpected in line 1/1. But have found a json3.js at github, but not only for that!

AFAIK CK Editor's script loader will expect JS, not JSON.
Therefore you will have to add this

var my_json = { "here" : "comes", "the" : "json" };

and (better) save the file als .js

Or try to use CKEDITOR.ajax to load JSON. Seems to work similar to jQuery.getJSON().
Both should work.

1 year ago
Post: 10987
Topic: Javascript in plugins

evtl. with PageRunScript hook function

The PageRunScript (filter) hook is rather meant to run PHP script code, mostly in order to modify the $page object by processing GET or POST data.
But you can also use it for pure AJAX responses or even let the execution stack exit with arbitrary output.

Edited: 1 year ago
Post: 10986
Topic: Javascript in plugins

It largely depends on when and where you need the JavaScript (see the docs)

Generally, you'll need

global $page, $addonRelativeCode;

Loading external scripts is best done via

$page->head .= '<script src="https://some.cdn/script.js"></script>';

while for local, static scripts it's

$page->head_js[] = $addonRelativeCode . '/some-local-static.js';

When placed in the GetHead (action) hook, it will always be loaded on every page.

If you only need the JS on a certain Admin_Link or Special_Link page, add it to the corresponding output method.
Same basically also applies to Gadgets (but it has to be noted that most themes load all Gadget assets by default unless they are disabled and re-added to certain layouts manually).

For adding JS components only required for editing certain section types, it's the InlineEdit_Scripts (filter) hook. AFAIK you cannot add external scripts via this (ajax called) hook because async loading components could break the crucuial loading order. But I haven't tried.


i want to load a .json file into a js-array and have found a json3.js at github, but not only for that!

In JS use $.getJSON(). It will return the json data (already parsed as JS array/object) to the success method.

In PHP, e.g. use

$my_json = file_get_contents('path/to/the/file.json');

Then you can decode it to a PHP array using

$array_from_my_json = json_decode($my_json);

for further processing.

Or simply output it to the page's JS via

$page->head_script .= "\nvar my_json = '" . $my_json . "';\n";

then you can use this JS

var my_data = JSON.parse(my_json);

to get an object/array from the data.



Edited: 1 year ago
Post: 10974
Topic: Ckeditor plugin manually install (Not replaced)

Thank You - but it still does not explain the difference between xammp and the web.

If it occurs with identical Typesetter versions, I can only imagine sth. with different PHP versions and the ZipArchive class.

1 year ago


Typesetter 5.1

Typesetter 5.0.1 is now available for download. 5.1 includes bug fixes, UI/UX improvements, ... Read More

Over 8 Times Faster Than Wordpress

We've known for a long time that Typesetter is fast. It's something we take pride ... Read More

More News

creisi productions

Dienstleistungen von creisi productions, Luzern (Schweiz): * Konzeption, Planung und Erstellung Ihres Internet-Auftritts * Betreuung und Aktualisierung/Pflege Ihrer Website * ...

Find out more about our Provider Spotlight

Log In