gutocf/page-title
最新稳定版本:1.2.0
Composer 安装命令:
composer require gutocf/page-title
包简介
Page Title component for CakePHP 4
关键字:
README 文档
README
Requirements
- PHP 8.1+
- CakePHP 5.0+
Note: For using with PHP 8.0 and CakePHP 4.3+ check out version 1.1.1
Installation
Install the plugin with composer
composer require gutocf/page-title
Plugin load
bin/cake plugin load PageTitle
Component load
Load the component in App\Controller\AppController:
$this->loadComponent('Gutocf/PageTitle.PageTitle', [ 'default' => 'MyApp Name', //Default page title - optional, default = null 'var' => 'var_name_for_views', //Var name to set at view - optional, default = title 'separator' => ' :: ', //Titles separator - optional, default = ' / ' 'reverseOrder' => true, //Display titles in reverse order of inclusion - optional, default = true ]);
You need to load the component in controllers or application's AppController (recomended).
Usage
To add titles to your page, simply call PageTitle::add method with one or more parameters:
$this->PageTitle->add('Articles', 'Add');
In Controller.beforeRender event, the component will set a variable with $config['var'] name for use in the views and templates, in this example Add :: Articles :: MyApp Name (Or MyApp Name :: Articles :: Add if reverseOrder option is false). You can set the page title by including this code in the template file src/templates/default.php
<head> <title><?= $this->get('var_name_for_views') ?></title> </head>
统计信息
- 总下载量: 4.31k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-09-15