Skip to:
Content
Pages
Categories
Search
Top
Bottom

Outputting individual bbpress topic counts to Google Geochart


  • tystra
    Participant

    @tystra

    I’m having trouble outputting specific topic counts for individual forums into Google’s Geochart. I want to have the total topic count listed on the map for each region (each forum). I use the following code to try and print the value, but I know I’m missing something (limited PHP/Javascript experience). Please take a look below, what do I need to add in order to get the value to output?

    <?php function my_geochart_script() {
            
       echo '<script type="text/javascript">
       google.load("visualization", "1", {"packages": ["geochart"]});
       google.setOnLoadCallback(drawRegionsMap);
     
       function drawRegionsMap() {
            var data = google.visualization.arrayToDataTable([
                    ["Country", "Popularity"],
                    ["Canada", <?php bbp_forum_topic_count( '23196' ); ?>],
                    ["Japan", <?php bbp_forum_topic_count( '23190' ); ?>],
            ]);
     
            var options = {backgroundColor:{fill:"transparent"}};
     
            var chart = new google.visualization.GeoChart(document.getElementById("chart_div"));
            chart.draw(data, options);
       };
       </script>';
    }
    add_action( 'wp_head', 'my_geochart_script' );

    Any help would be much much appreciated! Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Try bbp_get_forum_topic_count() instead, this ‘gets’ the value, without the ‘get’ using bbp_forum_topic_count() it tries to output the value.


    tystra
    Participant

    @tystra

    Thanks for the response, same problem, still outputs a blank page :/

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar