Routing Processwire,构建自己的url路由:/parent/child-to/child
Processwire的粉丝们好 我在Processwire中搜索更改自己的url路由的解决方案。 这是我在Processwire中的模板结构:Routing Processwire,构建自己的url路由:/parent/child-to/child,routing,processwire,Routing,Processwire,Processwire的粉丝们好 我在Processwire中搜索更改自己的url路由的解决方案。 这是我在Processwire中的模板结构: /categories (tpl_style_categories_parent.php) /cat1 (tpl_style_categories.php) /cat2 (tpl_style_categories.php) 目前的url是categories/cat1,但我只希望将/cat1作为url。 我怎样才能做到这一点 最好的方
/categories (tpl_style_categories_parent.php)
/cat1 (tpl_style_categories.php)
/cat2 (tpl_style_categories.php)
目前的url是categories/cat1,但我只希望将/cat1作为url。
我怎样才能做到这一点 最好的方法是在tpl_style_categories_parent(在您提供的结构中不可见)的父级上启用以捕获类别名称,并呈现相应页面的内容。该页面模板上非常简化的代码(此处不可见):
请务必阅读该链接中的所有内容,了解使用Url段的最佳做法。最好的方法是在tpl_style_categories_parent(在您提供的结构上不可见)的父级上启用以捕获类别名称,并呈现相应页面的内容。该页面模板上非常简化的代码(此处不可见):
确保阅读该链接中的所有内容,了解使用Url段的最佳实践I启用Url段并将代码添加到模板中。我尝试www.my-domain.de/cat1而不是www.my-domain.de/category/cat1。但它不起作用。在doku中,我找不到这样做的方法。你能帮我举一些工作示例吗?@chuebert也许你可以提供更多信息,例如,通过更新你的问题以包含更多你迄今为止尝试的代码示例。我启用Url段并将你的代码添加到模板中。我尝试www.my-domain.de/cat1而不是www.my-domain.de/category/cat1。但它不起作用。在doku中,我找不到这样做的方法。你能帮我举一些工作示例吗?@chuebert也许你可以提供更多的信息,例如,更新你的问题以包含更多你迄今为止尝试过的代码示例。。
if($input->urlSegment1) {
$name = $sanitizer->name($input->urlSegment1);
$category_page = $pages->get("template=tpl_style_categories, name={$name}");
echo $category_page->render();
} else {
// normal code for the template
}