c33s/simple-content-bundle

此包已被弃用且不再维护。没有建议的替代包。

symfony2 的基于路由的菜单系统

安装量: 1,226

依赖者: 1

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

类型:symfony-bundle

v0.12.2 2015-05-25 13:54 UTC

README

使用 Propel 驱动的内容块直接从您的 Twig 模板中。此包旨在用于小型到中型网站,其中原始内容在模板中硬编码,而不是使用 fixtures 以实现更快的开发。

只需将您的 HTML、文本或 Markdown 内容包装在一些 twig 过滤器中,您就可以使用了!

目前,此包依赖于 cedriclombardot/admingenerator-generator-bundle 进行内容编辑。我计划在未来将其分离。

此为进行中工作!请自行承担风险!

安装

在您的 composer.json 文件中要求 c33s/simple-content-bundle

{
    "require": {
        "c33s/simple-content-bundle": "0.11.*",
    }
}

app/AppKernel.php 中注册该包


    // app/AppKernel.php

    public function registerBundles()
    {
        return array(
            // ...

            new C33s\SimpleContentBundle\C33sSimpleContentBundle(),
        );
    }

覆盖 config.yml 中的选项

# app/config/config.yml

c33s_simple_content:
    # Set to true for automatic locale fallback
    use_locale_fallback:        false

确保定义了 %locales% 参数

# app/config/parameters.yml

parameters:
    locales: ['en', 'de']

使用

使用此包提供的 twig 过滤器,从模板中自动添加内容。

{# Just wrap your text inside the filter #}
<h1>{% filter c33s_content_line('home.title') %}Welcome to my website{% endfilter %}</h1>

{# You can force a specific locale #}
<h1>
    {% filter c33s_content_line('home.title', 'en') %}Welcome to my website{% endfilter %}
    {% filter c33s_content_line('home.title', 'de') %}Willkommen auf meiner Webseite{% endfilter %}
</h1>

{% filter c33s_content_markdown('home.welcome.text1') %}
This text will be _rendered_ using markdown.

Isn't it great?
{% endfilter %}

{% filter c33s_content_text('home.welcome.text2') %}
This text will only convert nl2br, but nothing else.

<strong>These tags won't have any effect</strong>
{% endfilter %}

{% filter c33s_content_html('home.welcome.text3') %}
Raw HTML content is possible, too.

<strong>This is strong.</strong>
{% endfilter %}

{# There is also a filter where the content type can be passed as an argument #}
{% filter c33s_content('home.title', 'line') %}Welcome to my website{% endfilter %}