You are here

yandex_metrics_reports.api.txt in Yandex.Metrics 7.2

Same filename and directory in other branches
  1. 8.2 yandex_metrics_reports/yandex_metrics_reports.api.txt

API usage example.

File

yandex_metrics_reports/yandex_metrics_reports.api.txt
View source
  1. /**
  2. * @file
  3. * API usage example.
  4. */
  5. /**
  6. * @addtogroup hooks
  7. * @{
  8. */
  9. /**
  10. * Implements of hook_yandex_metrics_reports_list().
  11. *
  12. * Provides metadata for custom reports.
  13. * You can add as many custom reports as you need.
  14. *
  15. * @return
  16. * An associative array of available reports.
  17. */
  18. function MYMODULE_yandex_metrics_reports_list() {
  19. $reports = array();
  20. // It's strongly recommended only use letters, numbers and underscores for keys of this array!
  21. $reports['my_custom_report'] = array(
  22. // Title of report/chart that is displayed on Reports settings and Summary Report pages.
  23. 'title' => t('My Custom Report'),
  24. // Callback function name that generates your report data.
  25. 'callback' => 'mymodule_my_custom_report',
  26. );
  27. return $reports;
  28. }
  29. /**
  30. * @} End of "addtogroup hooks".
  31. */
  32. /*
  33. * The example of user-defined callback for My Custom Report.
  34. *
  35. * It should handle $counter_id and $filter parameters.
  36. * This function MUST return HTML string, not an array or object.
  37. *
  38. * Make sure you escaped output to prevent security vulnerabilities.
  39. *
  40. * @see MYMODULE_yandex_metrics_reports_list()
  41. *
  42. * @param $counter_id
  43. * @param $filter
  44. * @return string
  45. */
  46. function MYMODULE_my_custom_report($counter_id, $filter) {
  47. return '

    ' . t('My custom report by') . check_plain($counter_id) . ' for ' . check_plain($filter) . '

    ';
  48. }