surda/返回按钮

Nette 框架的返回按钮控制

v2.0.0 2021-03-25 14:35 UTC

This package is auto-updated.

Last update: 2024-09-25 22:01:25 UTC


README

Build Status Licence Latest stable PHPStan

安装

推荐通过 Composer 安装

composer require surda/back-button

之后您需要在 config.neon 中注册扩展

extensions:
    backButton: Surda\BackButton\BackButtonExtension

配置

默认

backButton:
    defaultPresenterLink: 'default'
    templates:
        default: bootstrap4.default.latte
        secondary: bootstrap4.secondary.latte

所有配置选项的列表

backButton:
    defaultPresenterLink: 'default'
    useAjax: false
    template: path/to/your/latte/file.latte
    # or
    templates:
        default: path/to/your/latte/file.latte
        foo: path/to/your/latte/foo.latte
        ...

使用

演示者

use Nette\Application\UI\Presenter;
use Surda\BackButton\InjectBackButton;

abstract class ProductPresenter extends Presenter
{
    use InjectBackButton;
}

模板

源页面(例如产品:默认)添加链接到 default.latte

<a n:href="detail $id, destination => $currentLink">Detail</a>

目标页面(产品:详情)添加组件到 detail.latte

{control backButton}

目标

演示者

$this->template->destination = $this->link('detail', $id);

Latte

{control backButton destination:$destination}

选择控制模板文件

默认模板

{control backButton} or {control backButton default}  

通过模板类型设置控制模板(参见 config.neon)

{control backButton templateType}

重置

重置 URL 中的持久性参数 $destination ...?destination=%2Fproduct

<a n:href="default, destination => NULL">Products</a>

或所有(定义的)持久性参数

<a n:href="default, (expand) $resetPersistentParameters">Products</a>