To participate you must create an account on apostrophenow.org. If you have already done so, click Login.

Show
Ignore:
Timestamp:
04/26/10 17:08:58 (2 years ago)
Author:
tboutell
Message:

New default behavior of navigation components is appropriate for use on large sites with many pages. On small sites it may be slightly slower, in which case you can set app_a_many_pages to false to get the old "fetch the entire page tree and reuse it in each navigation component as needed" behavior back. This worked quite well up to about 1,000 pages but became a serious problem on an 8,000-page site.

aPage::getAncestorsInfo now has an optional 'includeSelf' parameter which defaults to false for backwards compatibility.

aPage::getInfo provides a page info array about the current page. Useful when merging information from the Info methods with information about pages you already have as objects.

aPage::getAccordionInfo now has an optional final parameter, 'root', which specifies the slug of the root page of the accordion tree. The page on which getAccordionInfo is called should be a descendant of that page (or the root page itself).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • plugins/apostrophePlugin/trunk/lib/navigation/aNavigationTabs.class.php

    r826 r1065  
    44{ 
    55  protected $cssClass = 'a-nav-item';  
    6   public function buildNavigation() 
     6  public function initializeTree() 
    77  { 
    8     $this->rootInfo = parent::$hash[$this->root]; 
    9     $this->activeInfo = parent::$hash[$this->active]; 
    10     $this->depth = $this->options['depth']; 
    11      
    12     if(isset($this->rootInfo['children'])) 
     8    if (sfConfig::get('app_a_many_pages', true)) 
    139    { 
    14       $this->nav = $this->rootInfo['children']; 
     10      // The use of the static sitewide page tree  
     11      // requires too much memory on sites with more 
     12      // than about 500-1000 pages. On smaller sites 
     13      // it turns out to be a performance win to get 
     14      // all of the page information for the site and 
     15      // cache it for subsequent navigation elements on 
     16      // the same page, which the base class does for us 
    1517    } 
    1618    else 
    1719    { 
    18       $this->nav = $this->rootInfo['parent']['children']; 
     20      parent::initializeTree(); 
    1921    } 
     22  } 
     23   
     24  public function buildNavigation() 
     25  { 
     26    if (sfConfig::get('app_a_many_pages', true)) 
     27    { 
     28      $activePage = aPageTable::retrieveBySlug($this->active); 
     29      $this->activeInfo = $activePage->getInfo(); 
     30       
     31      $rootPage = aPageTable::retrieveBySlug($this->root); 
     32      $this->rootInfo = $rootPage->getTreeInfo(false, $this->options['depth']); 
     33      // If no kids... 
     34      if (!count($this->rootInfo)) 
     35      { 
     36        // Try the parent 
     37        $rootPage = $rootPage->getParent(); 
     38        if (!$rootPage) 
     39        { 
     40          // Parent does not exist - this is the home page and there are no subpages 
     41          // (unlikely in practice due to admin pages) 
     42          $this->rootInfo = array(); 
     43        } 
     44        else 
     45        { 
     46          // Parent does exist, use its kids 
     47          $this->rootInfo = $rootPage->getTreeInfo(false, $this->options['depth']); 
     48        } 
     49      } 
     50      $this->nav = $this->rootInfo; 
     51    } 
     52    else 
     53    { 
     54      $this->rootInfo = parent::$hash[$this->root]; 
     55      $this->activeInfo = parent::$hash[$this->active]; 
     56      if(isset($this->rootInfo['children'])) 
     57      { 
     58        $this->nav = $this->rootInfo['children']; 
     59      } 
     60      else 
     61      { 
     62        if (!isset($this->rootInfo['parent'])) 
     63        { 
     64          // A site root with no children 
     65          $this->nav = array(); 
     66        } 
     67        else 
     68        { 
     69          $this->nav = $this->rootInfo['parent']['children']; 
     70        } 
     71      } 
     72    } 
     73    $this->depth = $this->options['depth']; 
     74     
    2075    $this->traverse($this->nav); 
    2176  }