gpt4 book ai didi

laravel - 十月 cms 博客的非英语 slug

转载 作者:行者123 更新时间:2023-12-04 01:53:55 24 4
gpt4 key购买 nike

使用十月 cms 的 build 422 和 Rainlab 博客插件,不可能有非英文 slug 的博客文章,每次都说“The slug format is invalid”。

是否有解决此限制的解决方案或变通方法?

最佳答案

我建议您关注 extending guide of octobercms并延长它。
这样您就可以安全地更新博客插件,而不必担心再次重新编辑它,或者当您必须重新安装 octobercms 时必须记住编辑它。

use Rainlab\Blog\Models\Post;

class Plugin extends PluginBase
{
public function boot()
{
// Extend post Model
Post::extend(function($model) {
// Only do stuff when validation is triggered
$model->bindEvent('model.beforeValidate', function() use ($model) {
// Find the regex holding value to avoid hardcoding array index
foreach($model->rules as $key => $value) {
if(strpos($value, 'regex:') !== false) {
// unset validation rule containing the regex.
unset($model->rules[$key]);
break;
}
}
}
});
}
}

关于laravel - 十月 cms 博客的非英语 slug,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51647902/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com