著名狼 / matomoapi
TYPO3 扩展,用于与 Matomo API 通信并在模板中显示
1.0.1
2021-05-17 08:02 UTC
Requires
- ext-json: *
- typo3/cms-core: ^10.4.2
Replaces
- typo3-ter/matomoapi: 1.0.1
This package is auto-updated.
Last update: 2024-09-17 21:05:52 UTC
README
TYPO3 扩展,用于连接到 Matomo API 并使用 Fluid 模板显示结果。
需求
- TYPO3 CMS 10.4
- PHP 7.2+
- 许可: GPL 3.0
手册
安装扩展后,您需要通过 TypoScript 配置 Matomo API 调用。然后,您可以通过 TypoScript 或作为内容元素添加插件。默认模板将使用 f:debug 显示返回的数据,所以您可能需要创建一个自定义模板。
有关 Matomo API 的更多信息,请参阅此处: https://developer.matomo.org/api-reference/reporting-api
TypoScript
示例
获取过去 30 天的访问次数
TypoScript
plugin.tx_matomoapi {
settings {
apiUrl = https://example.org/matomo/index.php?
tokenAuth = 1234567890abcdef1234567890abcdef
method = VisitsSummary.get
parameters {
idSite = 1
period = range
date = last30
}
}
}
Fluid 模板
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"> <f:layout name="Default" /> <f:section name="Content"> Visits in the last 30 days: {data.nb_visits} </f:section> </html>
获取昨天的最常访问页面 URL
TypoScript
plugin.tx_matomoapi {
settings {
apiUrl = https://example.org/matomo/index.php?
tokenAuth = 1234567890abcdef1234567890abcdef
method = Actions.getPageUrls
parameters {
idSite = 1
period = day
date = yesterday
flat = 1
filter_limit = 1
}
}
}
Fluid 模板
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"> <f:layout name="Default" /> <f:section name="Content"> <f:if condition="{data.0}"> <f:then> <a href="{data.0.url}">Most visited page yesterday</a> </f:then> <f:else> There were no visitors yesterday or something went wrong </f:else> </f:if> </f:section> </html>