Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5974631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:58:11+00:00 2026-05-22T20:58:11+00:00

Zend_Navigation extends Zend_Navigation_Container . The findOneBy() , findAllBy() , and findBy() functions all search

  • 0

Zend_Navigation extends Zend_Navigation_Container. The findOneBy(), findAllBy(), and findBy() functions all search for pages recursively, but removePage() does not. This means that $navigation->removePage($navigation->findOneBy('id', 'page_10')); will work ONLY if page_10 is a root-level navigation node. Has anyone else encountered this and found a work-around?


I have found my own solutions and accepted one of them as how I have implemented it. I will select a solution from someone else if it’s better than mine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:58:11+00:00Added an answer on May 22, 2026 at 8:58 pm

    Extend Zend_Navigation and Zend_Navigation_Container to recursively remove pages.

    Create My_Navigation_Container that extends Zend_Navigation_Container:

    abstract class My_Navigation_Container extends Zend_Navigation_Container
    {
        /**
         * Remove page(s) matching $property == $value
         *
         * @param string $property
         * @param mixed $value
         * @param bool $all
         * @return My_Navigation_Container
         */
        public function removeBy($property, $value, $all = false)
        {
            $pages = array();
    
            if ($all) {
                $pages = $this->findAllBy($property, $value);
            } else {
                if ($page = $this->findOneBy($property, $value)) {
                    $pages[] = $page;
                }
            }
    
            foreach ($pages as $page) {
                $this->removePageRecursive($page);
            }
    
            return $this;
        }
    
    
        /**
         * Recursively removes the given page from the container
         *
         * @param Zend_Navigation_Page $page
         * @return boolean
         */
        public function removePageRecursive(Zend_Navigation_Page $page)
        {
            if ($this->removePage($page)) {
                return true;
            }
    
            $iterator = new RecursiveIteratorIterator($this, RecursiveIteratorIterator::SELF_FIRST);
            foreach ($iterator as $pageContainer) {
                if ($pageContainer->removePage($page)) {
                    return true;
                }
            }
    
            return false;
        }
    }
    

    Make a copy of Zend_Navigation that extends My_Navigation_Container:

    class My_Navigation extends My_Navigation_Container
    {
        /**
         * Creates a new navigation container
         *
         * @param array|Zend_Config $pages    [optional] pages to add
         * @throws Zend_Navigation_Exception  if $pages is invalid
         */
        public function __construct($pages = null)
        {
            if (is_array($pages) || $pages instanceof Zend_Config) {
                $this->addPages($pages);
            } elseif (null !== $pages) {
                throw new Zend_Navigation_Exception('Invalid argument: $pages must be an array, an instance of Zend_Config, or null');
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been struggling with Zend_Navigation all weekend, and now I have another problem, which
With Zend_Navigation, I can do something like Home > Projects > Collaborators but What
I am trying to combine Zend_Navigation and Zend_Acl for URI pages, in a standalone
I use Zend_Navigation on my site. Most of the items are Zend_Navigation_Page_Mvc and NOT
I have my Zend_Navigation loaded from a PHP array (but that's irrelevant...) and I'm
Is there a way when using Zend_Navigation to set a separator for pages? For
I'm using an XML config file to populate my navigation using Zend_Navigation. I have
Examining Zend Framework, I found that all setter methods (of those I’ve examined) return
I'm using Zend_Navigation and am trying to integrate it with Zend_Acl . Each page
Is anyone using Zend Navigation in conjunction with URLs that require dynamic parameters? Zend_Navigation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.