dynamic data to initialize client controls

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
federico
Posts: 35
Joined: 27 Mar 2019, 17:35

dynamic data to initialize client controls

Post by federico »

Hello.

I use json to set up one of my plugin page user controls. I would like to add the following script in the page flow, having a php page to bring to the browser the needed data.

Code: Select all

<script type='text/javascript' src='" . plugin_file( 'data_source.php' ) . "'></script>
But I see the php file is not being processed if I use the "plugin_file" function, but it is properly loaded if I write the full path of the file. How can I achieve this using the mantis plugin architecture?

In addition, the data should be only loaded only for one of the pages, and the only way I found to add it in a safe way, is writing the pluging setup file, hooking the EVENT_LAYOUT_RESOURCES event.

How can I add scripts per page?

Thank you in advance
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: dynamic data to initialize client controls

Post by cas »

On the first question, I used something like :
echo '<script type="text/javascript" src="',config_get( 'path' ) . 'plugins/SapData/files/jquery.autocomplete.js' , '"></script>' . "\n";
Here you need to adjust everything behind "plugins/" to make it functional.

On your last question, I solved that by putting in the following statement in the routine ( as first lines):
if (substr($_SERVER['HTTP_REFERER'],-19) <> 'bug_update_page.php'){
return;
}
of course you need to adjust page name and length, but then it works perfectly
federico
Posts: 35
Joined: 27 Mar 2019, 17:35

Re: dynamic data to initialize client controls

Post by federico »

Thank you cas.

It worked for me.
Post Reply