I also make a tool class to generate the tree for use in a dropdown list as the symfony methods would not produce the formatting I needed.
<?php class GalleryAlbumTools { static function nested_dropdown_albums($userid) { // criteria for the object select below $c = new Criteria(); $c->add(GalleryAlbumPeer::USER_ID, $userid); $c->add(GalleryAlbumPeer::TREE_PARENT, 0); $c->addAscendingOrderByColumn(GalleryAlbumPeer::TREE_LEFT); $c->addAscendingOrderByColumn(GalleryAlbumPeer::TITLE); $rootAlbums = GalleryAlbumPeer::doSelect($c); $album_options = array(); foreach ($rootAlbums AS $parent) { $album_options[$parent->getId()] = $parent->getTitle(); if ($parent->hasChildren()) { foreach ($parent->getDescendants($peer_method = 'doSelect') AS $child) { $album_options[$child->getId()] = str_repeat('-',$child- >getLevel()).$child->getTitle(); } // end foreach } } return $album_options; } // end function nested_dropdown_albums } // end class ?> On Nov 18, 11:56 pm, gestadieu <[EMAIL PROTECTED]> wrote: > Can you share your finding? I will have to deal with this plugin soon > and I am interested to get your experience on this. Thx > > On Nov 18, 5:00 pm, lionslair <[EMAIL PROTECTED]> wrote: > > > I now got this sorted and working. > > > On Nov 17, 4:52 pm, lionslair <[EMAIL PROTECTED]> wrote: > > > > I need some help with the nested sets plugin. I am adding a gallery > > > to my site and allowing members to add albums. They can add root > > > albums and sub albums but am not able to add child albums. > > > > Here is my action. > > > > /** > > > * Execute action AddAlbum > > > * > > > */ > > > public function executeAddAlbum() > > > { > > > if ($this->getRequest()->getMethod() != sfRequest::POST) > > > { > > > return sfView::SUCCESS; > > > } > > > else > > > { > > > > $album = new GalleryAlbum(); // create new instance of the > > > gallery album object > > > > // there is no parent album set so make this album a root > > > album > > > if (!$this->getRequestParameter('album_parent_id')) > > > { > > > $album->makeRoot(); // all the function to build a new root > > > node object for the new albumn > > > } > > > else > > > { > > > // make this a child of an existing node > > > > > > $album->insertAsFirstChildOf($this->getRequestParameter('album_parent_id')) > > > ; > > > > } > > > > $album->setUserId($this->getRequestParameter('user_id')); > > > $album->setTitle($this->getRequestParameter('title')); > > > $album->setDescription($this->getRequestParameter('description')); > > > > $album->setDate($this->getRequestParameter('date')); > > > $album->setDisplay($this->getRequestParameter('display')); > > > $album->save(); > > > > $this->setFlash('class', 'confirmation'); > > > $this->setFlash('msg', 'Your new album has been created'); > > > $this->redirect('@photo_management'); > > > > } > > > } // end function executeAddAlbum > > > > The root albums seem to work but I can not add child albums. Can > > > someone point out what I am doing wrong. Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---