Need help creating a Template


#1

Hi there, im new programming in piwik, just about a month ago i started and i need some help with a template for a plugin im creating.

Im not really an english native so ill try to do my best writing so i can be understood.

Ok so, i have been developing a plugin for the last month and its almost ready, it gets a lot of data from an external DB thanks to Json format and it beautifully shows it on an Evolution graph. Problem is that now i need to do a combobox that works with this parameters (much like the worldmap plugin but those params are internal) and i have no clue on how working on templates. I dont know if i need to do the whole template and include the evolution graph in there or just the combobox and add it to the view or everything from scrath. i really cant find any docs for template tutorials, and reading the code for existing plugins have not work so any help would be really appreciated in this matter.


#2

I made the template and it works.

I used 2 templates in the same plugin, one with an evolutionGraph with all the data and the second a selfmade template called combo.tpl

I had to use 4 functions from the datatable.js file in the path, piwik/plugins/corehome/templates (function reloadAjaxDataTable; buildAjaxRequest; dataTableLoaded; notifyDashboardViewDataTableChange), which allow you from the selection on the combobox in the combo.tpl to refresh the datatable of the first template (evolutionGraph), you only have to use then to construct a new ‘get’, example: module=module_name&action=function_that_renders_evoGraph&idSite=?&period=?&date=?&jsonUrl=combo_selection

$jsonUrl is a param for my API function from which the evoGraph takes its data, the first time it loads show ‘no data for this graph’ but as soon as you make the selection it refresh only the evoGraph reciving the new parameter and getting the actual json url from which to get the data for displaying.

If any help post here and ill supply the code in another post if anyone asks to or i can send an email directly. Hope this can help anyone who is trying to work with json in piwik. Im very new to this so if you see better ways to make something similar to this work please tell me here.


(khouloud) #3

Hi,

I need to reload the dataTable in function of a data selected from a combobox. I think it’s exactly what you explained.

Thank you