Hi All,
Following this topic, I am trying to mess around a bit with regClientStartupHTMLBlock
so I can inject Google Charts into the head of the manager.
I am not being able to have it working. Not even for adding a meta tag.
Found some posts on the old Modx forum stating that this was working on Manager, but I couldn’t find anything conclusive on the Modx documentation mentioning this.
Do you have any idea if this works on manager pages?
The idea is to call the snippet from Migx schema and inject Google Charts code into the Head section as stated on this example:
I am placing that div inside migx form with success (checked on the Code view, and it is there, but not the Javascript.
Here is the snippet:
<?php
$headcode="<!--Load the AJAX API-->
<script type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"></script>
<script type=\"text/javascript\">
// Load the Visualization API and the corechart package.
google.charts.load('current', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.charts.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
data.addRows([
['Mushrooms', 3],
['Onions', 1],
['Olives', 1],
['Zucchini', 1],
['Pepperoni', 2]
]);
// Set chart options
var options = {'title':'How Much Pizza I Ate Last Night',
'width':400,
'height':300};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
";
$modx->regClientStartupHTMLBlock($headcode);
return;
And the section of Migx config calling the snippet:
{
"MIGX_id":2,
"caption":"Book edition",
"print_before_tabs":"0",
"fields":[
{
"MIGX_id":3,
"field":"Editions",
"caption":"Editions",
"description":"[[GenerateChart? &field=`Editions`]]<div id=\"chart_div\"></div><br><a href='?a=index&namespace=migx&configs=books_editions' target='_blank'>View all</a>`",
"description_is_code":"1",
"inputTV":"",
"inputTVtype":"migxdb",
"configs":"books_editions",
"restrictive_condition":"[[MigxCheckIfIsNewItem]]",
"sourceFrom":"config",
"sources":"[]",
"inputOptionValues":"",
"default":""
}
],
"pos":2
}
I made a small test.
Printed the var and applied a die()
and when checking the connector.php
response, the variable content is all there. So the snippet is being invoked properly.
Simply I am not being able to make the regClientStartupHTMLBlock
work…
Please, help the n00b 
Many thanks.
Cheers