/**
  * Gets immediate ancestor for the given node if it exists
  *
  * @param      sfBreadNav $node	Propel object for src node
  * @param      PropelPDO $con	Connection to use.
  * @return     mixed 		Propel object if exists else null
  */
 public static function retrieveParent(NodeObject $node, PropelPDO $con = null)
 {
     $c = new Criteria(sfBreadNavPeer::DATABASE_NAME);
     $c1 = $c->getNewCriterion(self::LEFT_COL, $node->getLeftValue(), Criteria::LESS_THAN);
     $c2 = $c->getNewCriterion(self::RIGHT_COL, $node->getRightValue(), Criteria::GREATER_THAN);
     $c1->addAnd($c2);
     $c->add($c1);
     if (self::SCOPE_COL) {
         $c->add(self::SCOPE_COL, $node->getScopeIdValue(), Criteria::EQUAL);
     }
     $c->addAscendingOrderByColumn(self::RIGHT_COL);
     $parent = sfBreadNavPeer::doSelectOne($c, $con);
     $node->setParentNode($parent);
     return $parent;
 }
Exemple #2
0
$catchall = false;
//get action and module
$c = new Criteria();
$c->add(sfBreadNavPeer::MODULE, $module);
$c->add(sfBreadNavPeer::ACTION, $action);
$c->add(sfBreadNavApplicationPeer::NAME, $menu);
$c->addJoin(sfBreadNavPeer::SCOPE, sfBreadNavApplicationPeer::ID);
$page = sfBreadNavPeer::doSelectOne($c);
if (!$page) {
    //page not found attempting to use catchall path
    $c = new Criteria();
    $c->add(sfBreadNavPeer::MODULE, $module);
    $c->add(sfBreadNavPeer::CATCHALL, 1);
    $c->add(sfBreadNavApplicationPeer::NAME, $menu);
    $c->addJoin(sfBreadNavPeer::SCOPE, sfBreadNavApplicationPeer::ID);
    $page = sfBreadNavPeer::doSelectOne($c);
    $catchall = true;
}
if ($page) {
    $path = $page->getPath();
    $id = $page->getId();
    foreach ($path as $node) {
        if ($node->getId() != $id || $node->getId() == $id && $catchall) {
            echo link_to($node->getPage(), $node->getModule() . '/' . $node->getAction());
        }
    }
}
if ($page) {
    if (!$catchall) {
        echo '<a href="#">' . $page->getPage() . '</a>';
    }