vladislavs / content-bundle
此包提供本地化内容管理
Requires
- php: >=5.3.3
- doctrine/orm: ~2.2,>=2.2.3
- jms/di-extra-bundle: ~1.4
- sensio/framework-extra-bundle: ~3.0
- symfony/framework-bundle: ~2.4
This package is not auto-updated.
Last update: 2024-09-23 15:19:01 UTC
README
许可证在此。
什么是Arcana内容包?
Arcana内容包允许管理员直接在页面上编辑文本,而不是在某个独立的Admin部分。
要求
- Symfony 2.4.x
- 请参阅composer.json中的
require
部分。
安装
可以通过Composer安装此包。您可以在packagist上找到此包:https://packagist.org.cn/packages/arcanacode/content-bundle
// composer.json
{
// ...
require: {
// ..
"arcanacode/content-bundle": "dev-master"
}
}
然后,您可以从存放composer.json文件的目录运行Composer的update命令来安装新依赖。
php composer.phar update
您必须将此包添加到AppKernel.php
的注册bundle方法中,以便Symfony可以使用它。
// in AppKernel::registerBundles() $bundles = array( // ... new Arcana\Bundle\ContentBundle\ArcanaContentBundle(), );
在您的config.yml
中,必须将此包添加到jms_di_extra。
jms_di_extra: locations: bundles: [ ArcanaContentBundle ]
接下来将bundle添加到'app/config/routing.yml'文件中。
arcana_content: resource: "@ArcanaContentBundle/Controller/" type: annotation
在基本模板文件中,仅对具有ROLE_ADMIN角色的用户包含样式表和javascripts。
{% if is_granted('ROLE_ADMIN') %} {% stylesheets filter="cssrewrite" "bundles/arcanacontent/vendor/raptor/raptor-custom-front-end.min.css" %} {% endstylesheets %} {% endif %} {% if is_granted('ROLE_ADMIN') %} {% javascripts "bundles/arcanacontent/vendor/raptor/raptor.custom.min.js" "bundles/arcanacontent/js/manager.js" %} <script src="{{ asset_url }}"></script>{% endjavascripts %} <script> window.arcana_content_manager.contentSaveUrl = '{{ path('arcana_content_save') }}'; </script>
{% endif %}
在基本模板的某个位置
window.arcana_content_manager.contentSaveUrl = '{{ path('arcana_content_save') }}';
在您的security.yml
文件中,仅对arcana_content_save路径限制管理员访问。
access_control: //.. - { path: ^/save, roles: ROLE_ADMIN }
最后,运行app/console doctrine:schema:update --force以在数据库中创建'content'表。
用法
为了使用此包,所有您想要编辑的文本都必须以以下格式添加到模板中,带有内容过滤器
{{ 'default value' | content('name', {options}) }}
'default value'是默认文本,如果数据库中找不到内容,则将显示该文本。'name'是内容表中内容的名称。'options' - 选项数组(如下所示)。示例
{{ 'Welcome to the Arcana Content Bundle!' | content('default_page_title', { editable_separately: true, type: 'plaintext' }) }}
您还可以使用不带默认值的大文本块(也带有html标签),例如
{% content of "facts_text" %} Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc rhoncus massa et dui tempor facilisis. In a luctus erat. Morbi eget tellus fermentum, pretium arcu sed, congue arcu. {% endcontent %}
单独可编辑的文本
{{ 'You can edit me separately' | content('separate_title_tag', { editable_separately: true, type: 'plaintext' }) }}
单独可编辑的文本是不可见的页面文本,例如 "title"标签。您可以通过打开"单独可编辑的内容"弹出窗口来编辑它们。
可用选项:'editable_separately' - 如果为'true',将在单独可编辑的内容弹出窗口中可编辑 'type': 'plaintext'/'block'/'inline'/'anchor' - 需要描述
贡献
欢迎拉取请求。
此处为描述。
运行Symfony2测试
此处为描述。