3

Expanding on this question here: dashlet creation

If I wanted to create my own dashlet with somewhat static content I'm wondering how that is accomplished, I have a loose idea below but not sure if it is correct.

How do I register the dashlet itself, since I won't be starting from a report - can I add a row to the database itself?

That row in the database would then point to a URL similar to the others (i.e. civicrm/dashlet/blog?reset=1). If I point to my own /dashlet/goodinfo... do I need to create both a supporting tpl and php file (kept neatly in a custom/override folder) or will a tpl file suffice?

I may be headed down an entirely incorrect path - open to suggestions!

1

When that other question mentions news dashlet I think it means the one called Blog, but yours sounds more similar to the Getting Started one - CRM/Dashlet/Page/GettingStarted.php.

Civix doesn't have a specific feature for dashlets, but you start with civix generate:page and copy/paste from the GettingStarted dashlet, although all you really need to do is optionally assign some smarty variables in run() in the autogenerated php class and edit the autogenerated .tpl with your html.

In the xml menu file that gets autogenerated it will have the url path you made up during the generate:page command. You need to insert an entry in civicrm_dashboard that links that url up to make it dashboard-worthy. See the function addGettingStartedDashlet() in CRM/Upgrade/Incremental/php/FourSeven.php, just note the columns have changed slightly if you're on a later version.

1

If you're on Drupal, you can use the civicrm_views_dashlets module for a no-coding solution. Not only can use create a view that shows a single page (which is editable like any other page), but you can use Views to show more complex content.

For instance, when I worked on a CiviCRM-based SaaS a few years back, we created our own "news" dashlet by publishing an RSS feed from a central site, which was picked up by the Drupal Feeds module to populate the View.

  • Awesome, thanks. I had seen this module but was a little unsure since it was last updated a few years ago and not 'covered by drupal's security policy'. – RayWright Mar 9 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.