2016-10-10 57 views
0

你好球迷Processwire的,Processwire,建立自己的URL路径:/父母/子女/儿童

我寻找一个解决方案来改变Processwire我自己的URL路由。 这是我的模板的结构Processwire:

/categories (tpl_style_categories_parent.php) 
    /cat1 (tpl_style_categories.php) 
    /cat2 (tpl_style_categories.php) 

的URL,现在是类别/ CAT1,但我想只/ CAT1的URL。 我如何使这可能?

回答

3

最好的方法是通过在tpl_style_categories_parent的父级上启用Url Segments(在您提供的结构中不可见)来捕获类别名称并呈现相应页面的内容。在模板上非常简单的代码页(一个在这里是不可见):

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 

} 

确保在链接来阅读一切知道使用URL段的最佳实践

+0

启用地址段和将您的代码添加到模板中。我尝试www.my-domain.de/cat1而不是www.my-domain.de/category/cat1。但它不起作用。在doku我没有办法做到这一点。你能帮我一些实际的例子吗? – chuebert

+0

@chuebert可能可以提供更多信息,例如通过更新你的问题,包括更多的代码示例,你到目前为止尝试了什么 – Can