zanderwar / silverstripe-thankfully
一个模块,旨在减少大型网站可能需要的数千个“感谢”页面
2.0.1
2017-06-15 05:47 UTC
Requires
- php: >=5.3.0
- silverstripe/cms: ~3.1
- silverstripe/framework: ~3.1
This package is auto-updated.
Last update: 2024-08-29 04:09:15 UTC
README
如果你厌倦了不得不不断创建成百上千个不同的“感谢”页面,那么很幸运,这个模块存在!
使用此模块,你可以轻松创建一个“感谢”页面,该页面可以在CMS中配置,适用于你分配此模块的任何页面类型。
特性
- 在dev/build下,页面自动创建在父级下
- 支持查询字符串,例如转换跟踪等,可在CMS中配置
安装
仅通过composer支持安装
$ composer require zanderwar/silverstripe-thankfully ~2.0
安装后运行dev/build
配置
- 打开你的
mysite/_config.php
文件 - 添加
ContactPage::add_extension('ThankfullyExtension'); ContactPage::add_extension('ThankfullyControllerExtension');
- 运行
?flush=1
- 在CMS中打开具有
ContactPage
(在本例中)类型的页面,你将现在看到一个“感谢”选项卡
在你的控制器(在本例中 ContactPage_Controller
)中,你现在可以访问 $this->getThankYouPage()
方法,然后你可以立即 return $this->redirect($this->getThankYouPage()->Link())
。这通常在表单处理方法中完成
如果扩展的页面标题和/或内容未在页面中设置,它将回退到在网站树根处由dev/build创建的 Thank You (Generic)
中设置的值,如果没有配置默认值,则访客将得到一个有点难看的使用体验
示例
class ExamplePage_Controller extends Page_Controller { private static $allowed_actions = array( 'index' ); public function index() { /** @var ThankfullyPage $thankYou */ $thankYou = $this->getThankYouPage(); $thankYou->setAllowed(true); // Required if "Always Allowed" is disabled in the CMS $thankYou->setReturnTo('/home/'); // Optional, if not provided the link to the parent page will be used return $this->redirect($thankYou->Link()); } }
贡献
如果你想为这个仓库做出贡献,请遵循贡献指南。
许可证
点击此处获取有关此模块许可的更多信息
问题
要报告此模块的问题,请使用我们的问题跟踪器。