Seeking Guidance on Implementing HighCharts in Joo

2019-09-03 17:25发布

We want to implement HighCharts in our custom Joomla module. Since it's a Javascript library, do we attach it to the view as a reference to the script files? I've also read about a PHP wrapper for HighCharts. Is it advisable to use it instead of the direct Javascript library?

1条回答
你好瞎i
2楼-- · 2019-09-03 17:30

To embed Javascript files into a Joomla module, you need to use the following code:

$document =& JFactory::getDocument();
$document->addScript(JURI::root() . "modules/mod_your_module/file.js");
$document->addScript(JURI::root() . "modules/mod_your_module/file2.js");
...

If you need to write custom Javascript, then you will need to write it like so:

$js = 'alert("alert message");';
$document->addScriptDeclaration($js);

Hope this helps.

查看更多
登录 后发表回答