定制 drinky78/shortcode-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

drinky78/shortcode-bundle

Composer 安装命令:

composer require drinky78/shortcode-bundle

包简介

Bundle that provides a Twig filter to support WordPress-like shortcodes.

关键字:

README 文档

README

Bundle that provides a Twig filter to support WordPress-like shortcodes.

Important: It's an early prototype!

Currently supported are tags of this form:

  • [demo] (simple tags)
  • [demo var=xxx var2=yyy] (tags with unquoted attributes)

Not yet supported are:

  • [demo]...[/demo] (tags with embedded content)
  • [demo var="xxx"] (tags with quoted attributes)

###Installation

Add ShortcodeBundle in your composer.json:

{
    "require": {
        "drinky78/shortcode-bundle": "dev-master"
    }
}

Register the bundle in AppKernel

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new MW\Bundle\ShortcodeBundle\MWShortcodeBundle(),
    );
}

##How to use:

###1. Create a new shortcode handler

<?php

#MyProject\Bundle\TestBundle\Shortcode\DemoShortcode.php

namespace MyProject\Bundle\TestBundle\Shortcode;

use MW\Bundle\ShortcodeBundle\Shortcode\BaseShortcode;

class DemoShortcode extends BaseShortcode
{

    public function parse($options)
    {
        // TODO: Render your content
        return 'Shortcode content';
    }

}

###2. Define the shortcode as a service (the alias will be the name of your shortcode):

<service id="myproject.shortcode.demo" class="MyProject\Bundle\TestBundle\Shortcode\DemoShortcode">
    <tag name="mw.shortcode" alias="demo" />
</service>

YML example

parameters:
    myproject.shortcode.demo: MyProject\Bundle\TestBundle\Shortcode\DemoShortcode

services:
    myproject.shortcode.demo:
        class: %myproject.shortcode.demo%
        tags:
            - { name: mw.shortcode, alias: demo }

###3. Use it in your Twig templates

<div>{{ page.content|shortcodes }}</div>

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-10-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固