custom route for doctrine nestedSet

我怕爱的太早我们不能终老 提交于 2019-12-11 23:24:07

问题


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.

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

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

In my actions.class.php file i have:

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

In my Animal model

    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 }

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

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

Thanks


回答1:


Try changing the route to be :

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


来源:https://stackoverflow.com/questions/6055603/custom-route-for-doctrine-nestedset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!