https://github.com/novactive/ezplatform-content-variables
Fork to contribute
https://github.com/novactive/ezplatform-content-variables
Last synced: 5 months ago
JSON representation
Fork to contribute
- Host: GitHub
- URL: https://github.com/novactive/ezplatform-content-variables
- Owner: Novactive
- License: gpl-2.0
- Created: 2020-12-15T20:39:34.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-16T02:54:02.000Z (about 2 years ago)
- Last Synced: 2025-03-19T01:48:07.584Z (about 1 year ago)
- Language: PHP
- Size: 240 KB
- Stars: 0
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eZ Platform Content Variables
This bundle provides a way to manage content variables. Basically, those are placeholders you can use anywhere in your content (in any field types). And they will be replaced with actual values during the page rendering.
## Installation
1. Require `contextualcode/ezplatform-content-variables` via `composer`:
```bash
composer require contextualcode/ezplatform-content-variables
```
2. Activate the bundle in `config/bundles.php`:
```php
ContextualCode\EzPlatformContentVariablesBundle\EzPlatformContentVariablesBundle::class => ['all' => true],
```
3. Add bundle routes in `config/routes/ezplatform_content_variables.yaml`:
```yaml
content_variables:
resource: "@EzPlatformContentVariablesBundle/Resources/config/routing.yaml"
```
4. Run the migrations:
- If you're using [Kaliop eZ-Migration Bundle](https://github.com/kaliop-uk/ezmigrationbundle)
```bash
php bin/console kaliop:migration:migrate
```
- If you're using [DoctrineMigrationsBundle](https://github.com/doctrine/DoctrineMigrationsBundle)
```bash
php bin/console doctrine:migrations:migrate --configuration=vendor/contextualcode/ezplatform-content-variables/src/bundle/Resources/config/doctrine_migrations.yaml
```
- If you're not using any migration bundle, execute SQL manually
```bash
mysql < vendor/contextualcode/ezplatform-content-variables/src/bundle/MigrationVersions/20191009101530_mysql_create_cc_content_variable_table.sql
```
5. Clear the caches:
```bash
php bin/console cache:clear
```
6. Compile the assets:
```bash
yarn encore dev
```
7. Update JavaScript translations:
```bash
php bin/console bazinga:js-translation:dump web/assets --merge-domains
```
## Usage
All the content variables are grouped in the collections. So first you would need to define those collections. To do so,
open an eZ Platform admin interface and go to "Content > Variables". And create a first content variables collection.
After the collection is created, you would need to add some variables. Click on the collection name and add
a few content variables. You would need to specify the following parameters for each variable:
- Name
- Identifier
- Value
There are two types of content variables: static and callback. No default callbacks are provided out of the box,
but it is very easy to create a new one:
1. Create a new `AppBundle\ContentVariables\Random` service (`src/AppBundle/ContentVariables/Random.php`),
which extends `ContextualCode\EzPlatformContentVariables\Variable\Value\Callback`.
```php