public function setHierarchicalSlug($tree, $slug = '')
 {
     foreach ($tree as $item) {
         $_title = sfSeoTransliterator::init()->setString($item['title'])->translit();
         if (!empty($slug)) {
             $_slug = $slug . '/' . $_title;
         } else {
             $_slug = $_title;
         }
         Doctrine_Query::create()->update('sfCategory c')->set('c.slug', '?', $_slug)->where('c.id = ?', $item['id'])->execute();
         if (is_array($item['__children'])) {
             $_item = $this->setHierarchicalSlug($item['__children'], $_slug);
         }
     }
 }
示例#2
0
 public function getHierarchicalSlug($tree, $slug = '')
 {
     foreach ($tree as $item) {
         $_title = sfSeoTransliterator::init()->setString($item['title'])->translit();
         if (!empty($slug)) {
             $_slug = $slug . '/' . $_title;
         } else {
             $_slug = $_title;
         }
         //var_dump($_slug);
         if (is_array($item['__children'][0])) {
             $_item = $this->getHierarchicalSlug($item['__children'], $_slug);
         }
     }
 }