Leif
Glad Johan was able to help you out.
For everybody else, what the plugin does is replicate the stuff your app's Index.html usually does, with some extras, but into the generated WordPress page. It does this via a PHP file called df4wp-page.php which can be found two ways:
- In your <WordPress-install-root>\wp-content\plugins\dataflex4wordpress\df4wp-page.php
- From within WordPress, login as an administrator and on the left-menu, go to Plugins --> Editor. Select the "Edit" link under the DataFlex4WordPress plugin and then on the right-pane, the df4wp-page.php file
In it you will find: function df4wp_webapp_page. This, among other things, builds up a string array called $df which will eventually be written out to the WordPress page. Around line 103 you should find:
Code:
array_push($df, "\n <!-- DataFlex Custom Controls (do not remove this line, used for automatic insertion) -->");
// Use the sizeFix.js script:
array_push($df, "\n <script src='", DF4WP_PLUGIN_URL, "/js/sizeFix.js'></script>\n");
Here you can add any special JavaScript your app needs, using (obviously) the same approach of building it into the $df string:
Code:
array_push($df, "\n <script src='" $apppath, "/RelativePathToYourJavaScriptFile'></script>\n");
The $apppath variable will hold the URL of your application (whatever would usually precede "/Index.html" when calling it), so that, with what follows it (where I've written "/RelativePathToYourJavaScriptFile") appended, should find your file. If it doesn't, your file will not get loaded. Getting this right may involve a bit of trial and error.
Do that for as many JavaScript files as your app requires.
Take care with this (backup copies would be good!), because any typos may stop your WordPress site from working at all (PHP is a good servant, but a horrible master!). Especially take care with the usage of the two different types of quotes.
As I am writing this, I'm thinking that maybe we should include this as a new pipe-separated string setting in the shortcode, to shield developers from the horrors of editing PHP. Something like:
Code:
customJS="js/MyScript1.js|custom/js/MyScript2.js|js/MyScript3.js"
We do need a new version of the plugin to work properly with DF 19 anyway and so this might be a good time to add such a feature. Opinions solicited.
Mike