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/aNavigationAccordion.class.php

    r837 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     if(isset($this->rootInfo['children'])) 
     8    if (sfConfig::get('app_a_many_pages', true)) 
    119    { 
    12       $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 
    1317    } 
    1418    else 
    1519    { 
    16       $this->nav = $this->rootInfo['parent']['children']; 
     20      parent::initializeTree(); 
    1721    } 
     22  } 
     23  public function buildNavigation() 
     24  { 
     25    if (sfConfig::get('app_a_many_pages', true)) 
     26    { 
     27      $activePage = aPageTable::retrieveBySlug($this->active); 
     28      $this->activeInfo = $activePage->getInfo(); 
     29      $this->rootInfo = $activePage->getAccordionInfo(false, null, $this->root); 
     30      // This rootInfo is already an array of kids 
     31      $this->nav = $this->rootInfo; 
     32    } 
     33    else 
     34    { 
     35      $this->rootInfo = parent::$hash[$this->root]; 
     36      $this->activeInfo = parent::$hash[$this->active]; 
     37      // This rootInfo is an individual page info 
     38      $this->nav = $this->rootInfo['children']; 
     39    } 
     40    // We no longer try to special case the situation where the root page has no children, 
     41    // because the active page should always be a descendant of the root page, and it 
     42    // complicated the implementation 
    1843    $this->traverse($this->nav); 
    1944  } 
     
    2651      $this->applyCSS($tree, $node); 
    2752       
    28       if(!self::isAncestor($node, $this->activeInfo) && !($node['id'] == $this->activeInfo['id'])) 
     53      // This is redundant if we used getAccordionInfo, and it won't work because we 
     54      // never set activeInfo or the 'parent' pointers 
     55      if (!sfConfig::get('app_a_many_pages', true)) 
    2956      { 
    30         unset($node['children']); 
     57        if(!self::isAncestor($node, $this->activeInfo) && !($node['id'] == $this->activeInfo['id'])) 
     58        { 
     59          unset($node['children']); 
     60        } 
    3161      } 
    3262