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

Add xlxs export option to Formie & Entries #320

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"nystudio107/craft-imageoptimize": "4.0.5",
"nystudio107/craft-vite": "4.0.9",
"percipioglobal/craft-password-policy": "4.1.0",
"phpoffice/phpspreadsheet": "^2.0",
"statikbe/craft-carbon-tracker": "^4.1",
"statikbe/craft-config-values": "^2.0.0",
"statikbe/craft-cookie-banner": "^3.0.0",
Expand Down Expand Up @@ -49,7 +50,8 @@
"optimize-autoloader": true,
"allow-plugins": {
"yiisoft/yii2-composer": true,
"craftcms/plugin-installer": true
"craftcms/plugin-installer": true,
"php-http/discovery": true
}
},
"scripts": {
Expand Down Expand Up @@ -78,4 +80,4 @@
"canonical": false
}
]
}
}
230 changes: 229 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions modules/statik/src/Statik.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
namespace modules\statik;

use Craft;
use craft\base\Element;
use craft\console\Application as ConsoleApplication;
use craft\elements\Entry;
use craft\elements\User;
use craft\events\RegisterComponentTypesEvent;
use craft\events\RegisterCpNavItemsEvent;
use craft\events\RegisterElementExportersEvent;
use craft\events\RegisterTemplateRootsEvent;
use craft\events\SetAssetFilenameEvent;
use craft\events\TemplateEvent;
Expand All @@ -16,6 +20,8 @@
use craft\web\twig\variables\CraftVariable;
use craft\web\View;
use modules\statik\assetbundles\Statik\StatikAsset;
use modules\statik\exporters\ElementXlsxExporter;
use modules\statik\exporters\SubmissionXlsxExporter;
use modules\statik\fields\AnchorLink;
use modules\statik\services\LanguageService;
use modules\statik\variables\StatikVariable;
Expand All @@ -25,6 +31,7 @@
use modules\statik\web\twig\PaginateExtension;
use modules\statik\web\twig\StatikExtension;
use modules\statik\web\twig\ValidateInputExtension;
use verbb\formie\elements\Submission;
use verbb\formie\events\RegisterFieldsEvent;
use verbb\formie\fields\formfields;
use yii\base\Event;
Expand Down Expand Up @@ -161,6 +168,32 @@ public function init(): void
}
});

if (Craft::$app->getPlugins()->enablePlugin('formie')) {
Event::on(
Submission::class,
Element::EVENT_REGISTER_EXPORTERS,
function(RegisterElementExportersEvent $event) {
$event->exporters[] = SubmissionXlsxExporter::class;
}
);
}

Event::on(
Entry::class,
Element::EVENT_REGISTER_EXPORTERS,
function(RegisterElementExportersEvent $event) {
$event->exporters[] = ElementXlsxExporter::class;
}
);

Event::on(
User::class,
Element::EVENT_REGISTER_EXPORTERS,
function(RegisterElementExportersEvent $event) {
$event->exporters[] = ElementXlsxExporter::class;
}
);

$this->setComponents([
'language' => LanguageService::class,
]);
Expand Down
Loading