contextualcode/ezplatform-content-variables 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

contextualcode/ezplatform-content-variables

Composer 安装命令:

composer require contextualcode/ezplatform-content-variables

包简介

eZ Platform bundle which provides dynamic content variables and UI to manage them

关键字:

README 文档

README

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:

    composer require contextualcode/ezplatform-content-variables
    
  2. Update routes in config/routes.yaml:

     content_variables:
         resource: "@EzPlatformContentVariablesBundle/Resources/config/routing.yaml"
    
  3. Run the migrations:

    php bin/console doctrine:migrations:migrate --configuration=vendor/contextualcode/ezplatform-content-variables/src/bundle/Resources/config/doctrine_migrations.yaml --no-interaction
    

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
        
     namespace AppBundle\ContentVariables;
        
     use ContextualCode\EzPlatformContentVariables\Variable\Value\Callback;
        
     class Random extends Callback
     {
         protected $identifier = 'random';
        
         public function getValue(): string
         {
             return random_int(0, 100);
         }
     }
    
  2. In the AppBundle\ContentVariables\Random service you need to:

    • Define $identifier property, it need to be unique in the scope of your project
    • Implement getValue function, it does not take any arguments and should return a string value. You can use any injected services in this function.
  3. Tag AppBundle\ContentVariables\Random with content_variables.value.callback:

     AppBundle\ContentVariables\Random:
         tags: [content_variables.value.callback]
    

Thats all, now when you add/edit any content variable you would be able to choose random callback for it.

After some content variables are created, you can use them in any content fields. To do so, please use a variable identifier wrapped with # sign. For example, if you have a variable with random_var identifier, try to add #random_var# to some pages content. And check edited content on the front-end siteaccess. An actual random number should be shown instead of #random_var#.

统计信息

  • 总下载量: 1.18k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-only
  • 更新时间: 2019-10-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固