Frontend\Core\Engine\Navigation::getPageInfo PHP Method

getPageInfo() public static method

Get more info about a page
public static getPageInfo ( integer $pageId ) : string
$pageId integer The pageID wherefore you want more information.
return string
    public static function getPageInfo($pageId)
    {
        // get navigation
        $navigation = self::getNavigation();
        // loop levels
        foreach ($navigation as $level) {
            // loop parents
            foreach ($level as $parentId => $children) {
                // loop children
                foreach ($children as $itemId => $item) {
                    // return if this is the requested item
                    if ($pageId == $itemId) {
                        // set return
                        $return = $item;
                        $return['page_id'] = $itemId;
                        $return['parent_id'] = $parentId;
                        // return
                        return $return;
                    }
                }
            }
        }
        // fallback
        return false;
    }

Usage Example

 /**
  * Load the data
  */
 private function loadData()
 {
     // get the current page id
     $pageId = $this->getContainer()->get('page')->getId();
     $navigation = FrontendNavigation::getNavigation();
     $pageInfo = FrontendNavigation::getPageInfo($pageId);
     $this->navigation = array();
     if (isset($navigation['page'][$pageInfo['parent_id']])) {
         $pages = $navigation['page'][$pageInfo['parent_id']];
         // store
         $pagesPrev = $pages;
         $pagesNext = $pages;
         // check for current id
         foreach ($pagesNext as $key => $value) {
             if ((int) $key != (int) $pageId) {
                 // go to next pointer in array
                 next($pagesNext);
                 next($pagesPrev);
             } else {
                 break;
             }
         }
         // get previous page
         $this->navigation['previous'] = prev($pagesPrev);
         // get next page
         $this->navigation['next'] = next($pagesNext);
         // get parent page
         $this->navigation['parent'] = FrontendNavigation::getPageInfo($pageInfo['parent_id']);
     }
 }
All Usage Examples Of Frontend\Core\Engine\Navigation::getPageInfo