自定义路线的nestedSet方法 [英] custom route for doctrine nestedSet

查看:75
本文介绍了自定义路线的nestedSet方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经能够成功地在前端的一棵漂亮的树中显示所有节点,但是问题出在实际页面的呈现上。

I have been able to to successfully display all the nodes in a nice tree on the frontend, but the problem comes with rendering of the actual pages.

所以我有2个父母,,并且有了它们,我有了多个子节点。

So I have 2 parents, Dog and Cat, and withing them I have multiple child nodes.

我创建了一个名为 animals 的前端模块,该模块具有一个空的 indexSuccess.php 文件。

I have created a frontend module named animals that has an empty indexSuccess.php file.

在我的 actions.class.php 文件中,我有:

$this->animal = AnimalTable::getAnimalBySlug($request->getParameter('slug'));

在我的动物模型中

    public static function getAnimalBySlug($slug)
    {
        $q = Doctrine_Query::create()
          ->from('Animal a')
          ->where("a.slug = ?", $slug);

       return $q->fetchOne();
    }

我有一条非常基本的路线:

I have a very basic route:

animal:
  url:   /:slug
  param: { module: animals, action: index }

所以您看到这对于 / dog (父节点)可以很好地工作,但不是对于 / dog / sheep-dog

So you see this will work fine for /dog (parent node), but not for /dog/sheep-dog

我不确定是否需要更新 getAnimalBySlug 以及采用NestedSet的动态路线ini的路线。

I'm not sure If i need to update my getAnimalBySlug and the route to take a dynamic route ini terms of a nestedSet.

谢谢

推荐答案

尝试将路线更改为:

animal:
  url:   /:slug
  param: { module: animals, action: index }
  requirements: { slug: '.*?' }

这篇关于自定义路线的nestedSet方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆