annotatecms / themes
dev-master
2018-01-21 19:43 UTC
Requires
- php: >=5.6
- annotate/diagnostics: @dev
- annotate/templating: @dev
- kdyby/events: ^3.1
- nette/application: ~2.4.0
- nette/bootstrap: ~2.4.0
- nette/di: ~2.4.0
- nette/finder: ~2.4.0
- tracy/tracy: ~2.4.0
Requires (Dev)
- codeclimate/php-test-reporter: @dev
- dotblue/codesniffer-ruleset: @dev
- jakub-onderka/php-console-highlighter: 0.*
- jakub-onderka/php-parallel-lint: 0.*
- latte/latte: ~2.4.0
- nette/tester: @dev
- phpspec/prophecy: ~1.4
- squizlabs/php_codesniffer: ^3.0
This package is not auto-updated.
Last update: 2022-02-01 13:15:58 UTC
README
Annotate 框架的主题包
此包提供了强大的主题支持。您可以创建主题并覆盖主题中的每个模板。
要求
主题扩展需要 annotate/templating。还需要将其扩展注册到 neon 配置中。
安装
通过 Composer 需要此扩展
$ composer require annotate/themes:~2.1.0
将扩展注册到配置中
extensions: templating: Annotate\Templating\DI\TemplatingExtension themes: Annotate\Themes\DI\ThemesExtension
配置
可以通过 Neon 配置主题路径。默认 directory
值为 %appDir%/app/addons/themes/
。要更改主题,请打开 app/config/app.neon 并添加以下配置
themes:
directory: %appDir%/app/
现在编辑您的任何演示者
class FrontendPresenter extends Nette\Application\UI\Presenter
{
use Annotate\Themes\ThemedPresenter;
/** @var Annotate\Themes\Loaders\ThemesLoader @inject */
public $themesLoader;
public function startup()
{
parent::startup();
$this->themesLoader->activateTheme('theme name');
}
}
创建主题
在主题目录中创建一个名为 theme_name.theme.neon
的文件,并具有最小结构
name: My theme
继承
主题支持单级继承,您可以通过 neon 文件中的 extends
选项指定父主题
name: My theme extends: theme
加载模板
激活主题后,应用程序将按以下方式搜索模板文件
- 搜索
%themeDir%/templates/%templateName
- 如果主题扩展了另一个主题,则搜索
%anotherThemeDir%/templates/%templateName%
- 如果未找到上述模板,则按常规 "Nette" 方式搜索文件