Friends, help us with advice.
Adding “HighCharts” to the page requires loading scripts to the head of the page and to the footer.
Charts are only displayed on certain pages.
It is undesirable to make separate templates for them.
Added fields (addscripthead and addscriptfooter) to the blueprint file with the path to the scripts.
How to code adding scripts correctly?
Now I’m doing this.
<?php if($page->uid() == 'pagechart'): ?> <?php echo js([ 'assets/js/chart/highcharts.js', 'assets/js/chart/sankey.js', 'assets/js/chart/organization.js', ]) ?> <?php endif ?>
<?php if ($page->uid() == 'pagechart'): ?> <?php echo js('assets/js/chart/chart.js') ?> <?php endif ?>
How do I check for the existence of a field? And if it is not empty, insert scripts.
I’ll add more details.
Thanks for the help.