pixelopen / sulu-flashinfobundle
Flash info bundle for Sulu
Installs: 29
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:sulu-bundle
Requires
- php: ^8.0
- sulu/sulu: ^2.5
- symfony/config: ^5.0 || ^6.0
- symfony/dependency-injection: ^5.0 || ^6.0
- symfony/framework-bundle: ^5.0 || ^6.0
- symfony/http-foundation: ^5.0 || ^6.0
- symfony/http-kernel: ^5.0 || ^6.0
Requires (Dev)
- dantleech/phpcr-migrations-bundle: ^1.3
- jackalope/jackalope-doctrine-dbal: ^1.3.2
- phpstan/phpstan: ^1.11
- symplify/easy-coding-standard: ^12.3
This package is not auto-updated.
Last update: 2024-10-30 16:25:19 UTC
README
Presentation
A bundle for the Sulu CMS that allows you to manage flash information displayed with a modal.
Features
- program your newsflashes
- modal in vanilla js (thank you Tingle https://tingle.robinparisi.com/)
- twig functions to display news flashes
Requirement
- PHP >= 8.0
- Sulu >= 2.5
- Symfony >= 5.4
- Composer
Installation
Install the bundle
Execute the following composer command to add the bundle to the dependencies of your project:
composer require pixelopen/sulu-flashinfobundle
Enable the bundle
Enable the bundle by adding it to the list of registered bundles in the config/bundles.php
file of your project:
return [ /* ... */ Pixel\FlashInfoBundle\FlashInfoBundle::class => ['all' => true], ];
Update schema
For the development environment:
bin/console do:sch:up --force
For the production environment: use doctrine migration
Bundle Config
Define the Admin Api Route in routes_admin.yaml
flash_info.flash_infos_api: type: rest prefix: /admin/api resource: pixel_flashinfo.flash-infos_route_controller name_prefix: flashinfo. flash_info.setting_api: type: rest prefix: /admin/api resource: pixel_flashinfo.setting_route_controller name_prefix: flashinfo.
Define the Website Api Route in routes_website.yaml
flash_infos_auto: path: /flash-infos-auto controller: Pixel\FlashInfoBundle\Controller\Website\FlashInfoAutoController::flashInfosAuto flash_infos_click: path: /flash-infos-click controller: Pixel\FlashInfoBundle\Controller\Website\FlashInfoClickController::flashInfosClick
Use
Add/Edit a news flash
To add a news flash, go to the "News flash" section and then, click on Add on the top of the page.
Once on the form, fill the following fields:
- Title (mandatory)
- Image
- Documents
- Start date (mandatory)
- End date (mandatory)
- Description (mandatory)
- Button label
- Link
Click on "Save" to save your news flash. To enable it, click on the "Active?" button on the top of the page.
To edit a news flash, click on the pencil of the news flash you wish to edit. This will take you to the same form as the add one.
Remove/Restore
There are 2 ways to delete a news flash:
- Go the edit form and click on the "Delete" button on the top of the page
- Check the news flash you want to delete and click on "Delete" on the top if the page
In both cases, the deleted news flash will be placed in the trash.
To restore a news flash, go to Settings > Trash and select the news flash you want to restore (by clicking on the reverse clock on the left). After the restoration, you will be redirected to the edit for.
To permanently delete a news flash, select it and click on the "Delete" button on the top of the page.
Settings
The settings allow you to set up how the news flash modal should be displayed. To access it, go to Settings > Newsflash management. You will have two parameters:
- A select which allows you to define if the modal should be opened automatically and how many times. It has the following options:
- Do not open: the modal is never opened automatically
- Open once: the modal is open on the first visit of the site (stored in a cookie)
- Open every time: the modal is opened each time during the user's visit
- A number input that is used to determine the cookie duration. By default, the duration is 30 days
Display modal
The modal will display the news flashes that are active with the current date in the period defined by the news flash.
The modal can be displayed automatically or by clicking a button.
Add the automatic modal opening
To use the automatic opening news flash modal, add the auto_display_flash_info_modal function to the head tag.
This function don't take any parameter.
<head> {{ auto_display_flash_info_modal() }} </head>
This Twig function will automatically display the modal according to the modal display policy (set in the settings) if there are published news flashes.
Add the modal opening on click
To use the modal opening on click, you need to use the display_flash_info_modal_on_click function.
This function must be placed in the head tag and takes one parameter:
- elementId: the id of the element that open the modal
<head> {{ display_flash_info_modal_on_click('flashInfo') }} </head> <body> <button class="flashInfo">Open the news flashes</button> </body>
This will display the modal no matter what the modal display policy is.
If there is no active news flash, an empty message will be shown.
Contributing
You can contribute to this bundle. The only thing you must do is respect the coding standard we implement.
You can find them in the ecs.php
file.