During the development of Lucius I build quite a lot of features, that are embedded in the product (an open source Drupal distribution). But we figured some of these might come in handy for other Drupal site owners to use, outside of the OpenLucius Drupal install profile.
So this is the first release I did: Simple Like Button, a very simple like button Drupal module that works in two steps:
- Install module
- Place block
- Done!
Features
- Instant feedback for end-user: count likes +1 or -1
- Adds names of users that liked the content
- It's compatible with all (custom) entities and bundles
- Compatible with all 'authenticated' roles, not with 'anonymous'.
- (non feature) Not compatible with Views at the moment.
Built with custom Drupal AJAX form
It's built with a custom AJAX Form, so we don't have to worry about building a custom AJAX route, a CSRF token and custom Javascripts to handle the user interactions.
While CSRF access checking looks like it can be easily integrated via xyz.routes.yml, ajax form was still more easy to implement.
Downside is that all forms can be cached, in high content site can lead up to unnecessary caching data.
And if you disagree on this approach, please let me know in the comments.
So anyway, if you are looking for a compact example of implementing an AJAX Form, check out the code of this module or the example in this blog.
Built with a Drupal custom entity
We used a Drupal entity for easy management of data:
- Defining the data model and database table, easy installable.
- CRUD: the Create, Read, Update and Delete queries are just easy if you work with Drupal entities.
So if you are looking for a compact example of implementing a custom entity, check out the code of this module.
And if you disagree on using a custom Drupal entity here, please let me know in the comments below.
Download the module
Please check out the project page on Drupal.org
