定制 symedit/theme-bundle 二次开发

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

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

symedit/theme-bundle

Composer 安装命令:

composer require symedit/theme-bundle

包简介

Theming for Symfony2

README 文档

README

symedit_theme:
    theme_directory: %kernel.root_dir%/../themes
    public_directory: themes
    active_theme: default
    templates:
        bundles: [AcmeDemoBundle]

The theme bundle will load templates from the `{theme_directory}/{active_theme}/templates folder. It also will allow you to use local assetic files. Themes are comprised of a simple YAML definition (in theme.yml):

name: default
parent: base
title: Default Theme
description: Default Theme for all websites
stylesheets:
    filters: [cssrewrite]
    inputs:
       - 'bundles/acmedemo/bootstrap/css/bootstrap.min.css'
       - 'bundles/acmedemo/css/font-awesome.min.css'
       - '@AcmeDemoBundle/Resources/less/site.less'
       - 'css/site.less' # Taken from /{active_theme}/css/site.less
javascripts:
    # Same as stylesheets
    inputs: []

You will now use your css in your templates like so:

{% stylesheets '@theme_css' %}
<link rel="stylesheet" href="{{ asset_url }}">
{% endstylesheets %}

You can always include other stylesheets there as well, the @theme_css is mostly to be able to access local assets inside your theme. Any bundle assets from other bundles can be intermixed:

{% stylesheets
    '@theme_css'
    '@AcmeDemoBundle/Resources/less/site.less' %}
<link rel="stylesheet" href="{{ asset_url }}">
{% endstylesheets %}

This same applies for javascripts as well and you can get it through assetic by @theme_js.

Parent Themes

You can set your theme to have a parent (should be the slug of the theme, and themes are located in %theme_dir%/{theme_name}/theme.yml). If your theme has a parent, then those templates are second in line to be used. After that are the overrides. If you use an override like "Framework" then templates being referenced like: @Framework/template.html.twig will instead use your theme directories to find a template. Likewise, if you use @Theme/template.html and it only existed in the @Framework namespace, it would still work.

When using a parent theme, you can also store your assets in any theme you'd like, or have them split up. It will start with your current theme and move up through all parents trying to locate the resource, so assets in your current theme take precedence. This helps if you have lots of similar themes so you can store shared assets in a "base" theme.

Templates

All your template includes and extends should use the @Theme namespace:

{% extends '@Theme/Page/base.html.twig' %}

{% block content %}
    {% include '@Theme/Includes/content.html.twig' %}
{% endblock %}

Parent Templates

You can also use the @Parent namespace to access parent templates. This allows you to easily override any part of a parent template without Twig trying to reference itself. If you're editing @Theme/Page/base.html.twig and a parent theme has the same template, you can extend it by using @Parent/Page/base.html.twig. It will search all parents starting with the most immediate until it finds one.

This should only be used in themes that don't, or won't have any children! If you extend a theme that uses @Parent references, the theme itself becomes the parent and will end up referencing itself.

Forms

You can select a template using the template form type:

$builder->add('page_template', 'template');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2014-05-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固