panlatent / element-messages
Element Messages for CraftCMS
Installs: 692
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 1
Open Issues: 1
Type:craft-plugin
Requires
- craftcms/cms: ^3.1.0
This package is auto-updated.
Last update: 2024-12-10 17:54:03 UTC
README
Element messages help your Craft application create messages between two elements and use any one element as the message content. It makes it easy to build relationships between three elements and provides a powerful way to query.We can customize the types of rich and flexible messages by sender element type, target element type and content element type. This relationship is stored in another database table, which helps reduce the data size of the Craft element relationship table. This should be a better solution for sending the same content multiple times (e.g. group sending).
Requirements
This plugin requires Craft CMS 3.1 or later.
Installation
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project
-
Then tell Composer to load the plugin:
composer require panlatent/element-messages
-
In the Control Panel, go to Settings → Plugins and click the “Install” button for Element Messages.
Usages
Create a message
<?php use panlatent\elementmessages\Plugin; $messages = Plugin::getInstance()->getMessages(); $message = $messages->createMessage([ 'senderId' => 1, 'targetId' => 2, 'contentId' => 3, ]); $messages->saveMessage($message);
Messages Query
<?php use panlatent\elementmessages\Plugin; $messages = Plugin::getInstance()->getMessages(); $results = $messages->findMessages([ 'senderId' => 1 ]); $total = $messages->getTotalMessages([ 'senderId' => 1, 'targetId' => 2, ]);
For more query conditions, please refer to panlatent\elementmessages\models\MessageCriteria
.
Documentation
- Read the Documentation: English.
License
The Element Messages is open-sourced software licensed under the MIT license.