{"id":21638792,"url":"https://github.com/novactive/ezplatform-content-variables","last_synced_at":"2026-04-14T00:01:44.479Z","repository":{"id":85026492,"uuid":"321783604","full_name":"Novactive/ezplatform-content-variables","owner":"Novactive","description":"Fork to contribute","archived":false,"fork":false,"pushed_at":"2024-01-16T02:54:02.000Z","size":246,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-19T01:48:07.584Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Novactive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-15T20:39:34.000Z","updated_at":"2020-12-15T23:13:07.000Z","dependencies_parsed_at":"2025-03-19T01:47:53.019Z","dependency_job_id":"0989bc6a-b85e-426c-a570-b637e3abde23","html_url":"https://github.com/Novactive/ezplatform-content-variables","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/Novactive/ezplatform-content-variables","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Novactive%2Fezplatform-content-variables","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Novactive%2Fezplatform-content-variables/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Novactive%2Fezplatform-content-variables/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Novactive%2Fezplatform-content-variables/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Novactive","download_url":"https://codeload.github.com/Novactive/ezplatform-content-variables/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Novactive%2Fezplatform-content-variables/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280790807,"owners_count":26391689,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-24T02:00:06.418Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-25T04:11:43.905Z","updated_at":"2025-10-24T11:42:04.260Z","avatar_url":"https://github.com/Novactive.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# eZ Platform Content Variables\n\nThis 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.\n\n## Installation\n\n1. Require `contextualcode/ezplatform-content-variables` via `composer`:\n    ```bash\n   composer require contextualcode/ezplatform-content-variables\n    ```\n   \n2. Activate the bundle in `config/bundles.php`:\n    ```php\n    ContextualCode\\EzPlatformContentVariablesBundle\\EzPlatformContentVariablesBundle::class =\u003e  ['all' =\u003e true],\n    ```\n\n3. Add bundle routes in `config/routes/ezplatform_content_variables.yaml`:\n    ```yaml\n    content_variables:\n        resource: \"@EzPlatformContentVariablesBundle/Resources/config/routing.yaml\"\n    ```\n\n4. Run the migrations:\n\n    - If you're using [Kaliop eZ-Migration Bundle](https://github.com/kaliop-uk/ezmigrationbundle)\n        ```bash\n        php bin/console kaliop:migration:migrate\n        ```\n\n    - If you're using [DoctrineMigrationsBundle](https://github.com/doctrine/DoctrineMigrationsBundle)\n        ```bash\n        php bin/console doctrine:migrations:migrate --configuration=vendor/contextualcode/ezplatform-content-variables/src/bundle/Resources/config/doctrine_migrations.yaml\n        ```\n\n    - If you're not using any migration bundle, execute SQL manually\n        ```bash\n        mysql \u003c vendor/contextualcode/ezplatform-content-variables/src/bundle/MigrationVersions/20191009101530_mysql_create_cc_content_variable_table.sql\n        ```\n\n5. Clear the caches:\n    ```bash\n    php bin/console cache:clear\n    ```\n\n6. Compile the assets:\n    ```bash\n    yarn encore dev\n    ```\n\n7. Update JavaScript translations:\n    ```bash\n    php bin/console bazinga:js-translation:dump web/assets --merge-domains\n    ```\n\n## Usage\n\nAll the content variables are grouped in the collections. So first you would need to define those collections. To do so,\nopen an eZ Platform admin interface and go to \"Content \u003e Variables\". And create a first content variables collection.\n\nAfter the collection is created, you would need to add some variables. Click on the collection name and add\na few content variables. You would need to specify the following parameters for each variable:\n- Name\n- Identifier\n- Value\n\nThere are two types of content variables: static and callback. No default callbacks are provided out of the box,\nbut it is very easy to create a new one:\n\n1. Create a new `AppBundle\\ContentVariables\\Random` service (`src/AppBundle/ContentVariables/Random.php`),\nwhich extends `ContextualCode\\EzPlatformContentVariables\\Variable\\Value\\Callback`.\n    ```php\n    \u003c?php\n    \n    namespace AppBundle\\ContentVariables;\n    \n    use ContextualCode\\EzPlatformContentVariables\\Variable\\Value\\Callback;\n    \n    class Random extends Callback\n    {\n        protected $identifier = 'random';\n    \n        public function getValue(): string\n        {\n            return random_int(0, 100);\n        }\n    }\n    ```\n\n2. In the `AppBundle\\ContentVariables\\Random` service you need to:\n    - Define `$identifier` property, it need to be unique in the scope of your project\n    - Implement `getValue` function, it does not take any arguments and should return a string value.\n    You can use any injected services in this function.\n\n3. Tag `AppBundle\\ContentVariables\\Random` with `content_variables.value.callback`:\n    ```yaml\n    AppBundle\\ContentVariables\\Random:\n        tags: [content_variables.value.callback]\n    ```\n\nThats all, now when you add/edit any content variable you would be able to choose `random` callback for it.\n\nAfter some content variables are created, you can use them in any content fields. To do so, please use a variable\nidentifier wrapped with `#` sign. For example, if you have a variable with `random_var` identifier,\ntry to add `#random_var#` to some pages content. And check edited content on the front-end siteaccess.\nAn actual random number should be shown instead of `#random_var#`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnovactive%2Fezplatform-content-variables","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnovactive%2Fezplatform-content-variables","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnovactive%2Fezplatform-content-variables/lists"}