@tmuic opened this issue on June 8th 2016

On Pages and some other reports page URLs are automatically generated when URL is detected. On Intranet installations this is problematic behaviour since it might be that Piwik is on separate server and that pages are not accessible from computer which Piwik is accessed from

Would it be possible to add parameter that makes links unclickable in that situation?

I am willing to fix that myself if I get a few pointers how to get started (propably add site setting and access it somehow from twig?)

piwik/plugins/CoreHome/templates/_dataTableCell.twig

{% if not row.getIdSubDataTable() and column=='label' and row.getMetadata('url') %}
    <a rel="noreferrer"
       target="_blank"
       href='{% if row.getMetadata('url')|slice(0,4) not in ['http','ftp:'] %}http://{% endif %}{{ row.getMetadata('url')|rawSafeDecoded }}'>
    {% if not row.getMetadata('logo') %}
        <img class="link" width="10" height="9"
             src="plugins/Morpheus/images/link.gif"/>
    {% endif %}
{% endif %}

(I added style="pointer-events: none" as a temporary workaround to my piwik installation)

@tsteur commented on June 10th 2016

I think this would be a perfect use case to solve in a plugin.

Rough idea would be to create a plugin see http://developer.piwik.org/guides/getting-started-part-1

Then listen to the event http://developer.piwik.org/guides/events called API.Request.dispatch.end see http://developer.piwik.org/api-reference/events#apirequestdispatchend or you could listen to only a specific API method via the API.$pluginName.$methodName.end http://developer.piwik.org/api-reference/events#apipluginnamemethodnameend event.

When your event is triggered you could check if the response is a Piwik\DataTable and if so, unset all url metadata eg $row->deleteMetadata('url').

You could make the plugin even configurable eg by adding a config entries in config/config.ini.php that you can access with Piwik\Config class see http://developer.piwik.org/api-reference/Piwik/Config . For example could be

[MyPluginName]
intranet_urls[] = "..."
intranet_urls[] = "..."

does this help?

@tmuic commented on June 10th 2016

I will try that. I have already created plugin so this seems be good way to go. Not sure how will I share this with community. Plugin for such small isolated feature seems to much

@tsteur commented on June 10th 2016

I'm sure some other users would be interested in such a plugin / feature as well as Piwik is often used in an intranet. You could share it via our Marketplace see http://developer.piwik.org/guides/distributing-your-plugin

@mattab commented on July 8th 2016

Hi @tmuic we look forward to seeing your plugin on the marketplace :+1:

Powered by GitHub Issue Mirror