devtronic / cms-bundle
此包已被废弃,不再维护。没有建议的替代包。
Symfony3 CMS Bundle
v1.0.5
2017-04-01 07:19 UTC
Requires
- php: >=5.3.3
- egeloen/ckeditor-bundle: ^4.0
Suggests
- sonata-project/admin-bundle: For using the admins
This package is auto-updated.
Last update: 2021-08-07 20:30:15 UTC
README
状态
完成
- 英文翻译
- 德文翻译
- 在 Twig 模板中显示菜单
- 菜单、MenuItem、Page 实体
- Sonata Admins
- 使菜单模板更动态
开放
- 多语言数据库内容
- 等等... :)
安装
$ composer require --dev devtronic/cms-bundle
<?php use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new Ivory\CKEditorBundle\IvoryCKEditorBundle(), new Devtronic\CmsBundle\CmsBundle(), ); // ... return $bundles; } // ... }
Symfony >= 3.x
$ php bin/console assets:install --symlink --relative $ php bin/console doctrine:schema:update --force $ php bin/console cache:clear
Symfony <= 2.8.x
$ php app/console assets:install --symlink --relative $ php app/console doctrine:schema:update --force $ php app/console cache:clear
配置
# app/config/routing.yml devtronic_cms_bundle: resource: "@CmsBundle/Controller/" type: annotation prefix: /cms # OR WHAT EVER YOU WANT (links goes example.com/cms/{page-slug})
用法
在 twig-template 中显示菜单
{# anything.html.twig #} {{ cms_menu("MENU SLUG GOES HERE") }} {# or with a custom Menu Template #} {{ cms_menu("MENU SLUG GOES HERE", "AnyBundle:Path:menu_template.html.twig") }}
模板
菜单模板
{# app/Resources/CmsBundle/views/menu.html.twig #} {# Types: 0: CMS Page, 1: Hyperlink, 2: Route #} {# Top-Level Menu Entries #} {% if menu.items is defined %} <ul class="nav navbar-nav"> {% for item in menu.items %} {% if item.parentItem is null %} {% if item.subItems | length %} <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ item.title }} <span class="caret"></span></a> {% include 'CmsBundle::menu.html.twig' with {'menu': item} %} </li> {% else %} <li> {% if item.type == 0 %} <a href="{{ path('cms_page', {'slug': item.targetPage.slug}) }}">{{ item.title }}</a> {% elseif item.type == 2 %} <a href="{{ path(item.targetUrl) }}">{{ item.title }}</a> {% else %} <a href="{{ item.targetUrl }}">{{ item.title }}</a> {% endif %} </li> {% endif %} {% endif %} {% endfor %} </ul> {# Sub-Entries #} {% elseif menu.subItems is defined %} <ul class="dropdown-menu"> {% for item in menu.subItems %} {% if item.subItems | length %} <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ item.title }} <span class="caret"></span></a> {% include 'CmsBundle::menu.html.twig' with {'menu': item} %} </li> {% else %} <li> {% if item.type == 0 %} <a href="{{ path('cms_page', {'slug': item.targetPage.slug}) }}">{{ item.title }}</a> {% elseif item.type == 2 %} <a href="{{ path(item.targetUrl) }}">{{ item.title }}</a> {% else %} <a href="{{ item.targetUrl }}">{{ item.title }}</a> {% endif %} </li> {% endif %} {% endfor %} </ul> {% endif %}
页面模板
{# app/Resources/CmsBundle/views/Page/page.html.twig #} {% extends "::base.html.twig" %} {% block title %}{{ page.title }}{% endblock %} {% block body %} <h1>{{ page.title }}</h1> {{ page.content | raw }} {% endblock %}
索引模板
{# app/Resources/CmsBundle/views/Page/index.html.twig #} {% extends "::base.html.twig" %} {% block title %}{{ page.title }}{% endblock %} {% block body %} <h1>{{ page.title }}</h1> {{ page.content | raw }} {% endblock %}
常见问题解答 (FAQ)
如何链接到主页?
作为菜单条目:内部路由到 cms_index。在模板中作为链接: <a href="{{ path('cms_index') }}">主页</a>
如何贡献?
翻译此包(将
messages.LOCALE.xlf
和您的用户名发送到 admin@developer-heaven.de
翻译状态
语言 | 翻译者 | 状态 |
---|---|---|
德语 | Devtronic | 100% |
英语 | Modius22 | 100% |