kuriousagency/bigreports 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

kuriousagency/bigreports

最新稳定版本:1.1.5

Composer 安装命令:

composer require kuriousagency/bigreports

包简介

Run reports on large data sets.

README 文档

README

Big Reports is a plugin that allows you to create reports using Twig and have the results emailed to you as a CSV. Ideal for large data sets.

Requirements

This plugin requires Craft CMS 3.0.0 or later.

Installation

To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:

    cd /path/to/project
    
  2. Then tell Composer to load the plugin:

    composer require kuriousagency/bigreports
    
  3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Craft Reports.

Craft Reports Overview

Set your columns by using the craft.bigreports.service.columns() method, then add your row data by using the craft.bigreports.service.row().

Last thing to do is to use the craft.bigreports.service.data() method to output the data.

Here is an example report in Twig:

{% do craft.bigreports.service.columns(["Firstname", "Lastname", "email"]) %}

{% for user in craft.users.limit(null).all() %}
	{% do craft.bigreports.service.row([
		user.firstName,
		user.lastName,
		user.email
	]) %}
{% endfor %}

{{ craft.bigreports.service.data }}

Options

Big Reports can have options that are based on Craft CP forms macro.

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

These options can then be accessed in the results. Here's an example that lists all users that have registered between two dates

{% set users = craft.users.
	dateCreated(['and','>= ' ~ options.startDate|date('c'),'<= '~ options.endDate|date('Y-m-d 23:59:59')|date('c')])
	.all() %}

{% do craft.bigreports.service.columns(["Firstname","LastName","Email"]) %}

{% for user in users %}
	{% do craft.bigreports.service.row([
        user.firstName,
        user.lastName,
        user.email,
    ]) %}
{% endfor %}

{{ craft.bigreports.service.data }}

The results are sent as a CSV attachment to the email address specifed on the report

Example User Res Setting

Configuring Big Reports

Reports Template Path

Set the directory to find report templates

Here's an example folder structure

templates
   _reports
       users
          results.twig
          settings.twig

In the above case you would enter _reports as the template path

Email Template Path

If you would like to use your own email template to send the report you can set it here

Example files

Examples can be found here: https://github.com/KuriousAgency/craft-bigreports/tree/master/examples

Brought to you by Kurious Agency

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2019-03-07