定制 peet86/craft-reports 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

peet86/craft-reports

Composer 安装命令:

composer require peet86/craft-reports

包简介

Reports for Craft 3

README 文档

README

Write reports with Twig.

Screenshot

Installation

To install Reports, follow these steps:

  1. Download & unzip the file and place the reports directory into your craft/plugins directory
  2. Install plugin in the Craft Control Panel under Settings > Plugins
  3. The plugin folder should be named reports for Craft to see it.

Reports works on Craft 2.4.x and higher;

Reports Overview

Reports allow you to collect data by writing Twig tags as normal. All you need to in the end is pass that data to the .prepare() method, like the following example:

Example report in Twig:

{% set newsCount = craft.entries.section('news').limit(null).total() %}
{{ craft.reports.prepare({
    columns: ['Total news entries'], 
    rows: [ [ newsCount ] ]
}) }}

List all users in a specific user group that have logged in within the last 30 days:

{% set loginPeriod = now|date_modify('-30 days') %}
{% set users = craft.users.group('clients').lastLoginDate('> ' ~ loginPeriod) %}
{% set userRows = [] %}
{% for user in users %}
    {% set userRows = userRows|merge([ [user.username, user.getName(), user.email] ]) %}
{% endfor %}

{{ craft.reports.prepare({
    columns: ['Username', 'Name', 'Email'], 
    rows: userRows
}) }}

The result is available in the control panel, or as a CSV export.

You can register report types from other plugins and use templates for both options and results:

public function registerReports()
{
    $types = [];
    $folders = IOHelper::getFolders(craft()->path->getPluginsPath().'tester/templates/reports/');
    
    foreach($folders as $folder){
        $name = IOHelper::getFolderName($folder, false);
        $types[$name] = 'reports/'.$name;
    }
    
    return $types;
}

Use the reports forms variable to access cp forms macros

{{ craft.reports.forms('dateTimeField', {
	id: 'startDate',
    label: "Start Date"|t,
    name: 'options[startDate]',
    value: options.startDate
}) }}

The options variable is now available in the results.twig

folder structure:

templates
    reports
        reportType
            results.twig
            settings.twig

Based on the work by Superbig

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2019-01-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固