Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow plugins to create new View types for reports in widgets #1571

Closed
gka opened this issue Aug 10, 2010 · 4 comments
Closed

Allow plugins to create new View types for reports in widgets #1571

gka opened this issue Aug 10, 2010 · 4 comments
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical. wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it.

Comments

@gka
Copy link
Contributor

gka commented Aug 10, 2010

In fact most of the Piwik widgets already have multiple "pages". The first one is the data table, the second is the extended data table and then followed by several charts (bar, pie) and the tag cloud. I think this is a very good way of providing multiple presentations to the same data and it would be take this feature a little further.

problem definition

By now the multi-page widget is implemented inside one view (ViewDataTable). As a plugin developer it is very hard to understand this implementation (at least it is hard for me) and it seems impossible to add new "pages" to existing widgets without hacking the Piwik core. Why not moving the multi-page widget implementation into the widget architecture?

proposal

Each widget is able to define one or many pages. If there is only one page, the output is simply printed into the widget container. But if a widget defines multiple pages, the widget autmatically displays ui elements to let the user change the page (currently the icon bar footer).

To define a mulitple-page widget, the developer has to provide the following information for each widget page:

  • id (unique inside the widget)
  • icon filename (displayed in the icon bar)
  • translated title (displayed in the icons tooltip)
  • controller function that renders the widget page

benefits

Keywords: interesting

@mattab
Copy link
Member

mattab commented Aug 16, 2010

You mention having possibility for plugins to define new 'view types'. I think this would be doable by adding a hook in the viewdatatable factory for example, and having the datatatable footers load the new icon, translations, etc.

@gka
Copy link
Contributor Author

gka commented Aug 16, 2010

Adding a hook in the viewdatatable would at least make it easier to add new views to the current datatable.

But I also thought about going one step further. The viewdatatable introduces a nice icon footer into many widgets used in Piwik. By now, this icon footer is not very reusable. In fact, if someone is going to write completely new multi-view widgets that integrate well in the current Piwik UI he would have to rebuild the icon footer by hand (including html setup and js functionality like auto-hide and last-view-saving). This is what I did while creating the map widget.

So my idea was to move the multi-view code from the viewdatatable to the Piwik core in a way that every new widget can easily create new views.

Another option would be to create an abstract multi-view widget which would be extended by the viewdatatable or any other new multi-view widgets. However, the UI logic for the icon footer should use a single codebase.

@anonymous-matomo-user
Copy link

Unfortunately I have no time to do this myself, but here's the general idea:

you need to modify plugins/CoreHome/templates/datable_footer.tpl to somehow include custom icons (maybe another if, for example if $properties.customicons with a foreach), specifically the section {if $properties.show_all_views_icons}. The format attribute of <a> is the one passed over GET and recognized by ViewDataTable::factory, the var attribute tells the javascript which button to display when the icons are grouped and this one is selected.

You then need to modify ViewDataTable::factory to maybe check if the class passed over GET exists, if yes return a new object of that class, else revert to default. Also a new method to add custom icons is required, it would set $this->viewProperties['customicons'] to an array of the specified icons.

Your plug-in class (the one returned by ViewDataTable::factory) needs to have one method

protected function getViewDataTableId()
{
   return 'something';
}

where something is the same string as in the var attribute of <a> in datable_footer.tpl

I think that's all you need to do, but I'm not sure.

@mattab
Copy link
Member

mattab commented Nov 24, 2010

I agree with the concept, but you worked around nicely in #1558.

I don't think we will be adding this feature at this stage. Let's reopen the ticket if need be :)

@gka gka added this to the Future releases milestone Jul 8, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical. wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it.
Projects
None yet
Development

No branches or pull requests

3 participants