Backend\Modules\Pages\Engine\Model::getTreeHTML PHP Method

getTreeHTML() public static method

Get the tree
public static getTreeHTML ( ) : string
return string
    public static function getTreeHTML()
    {
        $navigation = static::getCacheBuilder()->getNavigation(BL::getWorkingLanguage());
        // start HTML
        $html = '<h4>' . \SpoonFilter::ucfirst(BL::lbl('MainNavigation')) . '</h4>' . "\n";
        $html .= '<div class="clearfix" data-tree="main">' . "\n";
        $html .= '    <ul>' . "\n";
        $html .= '        <li id="page-1" rel="home">';
        // create homepage anchor from title
        $homePage = self::get(1);
        $html .= '            <a href="' . BackendModel::createURLForAction('Edit', null, null, array('id' => 1)) . '"><ins>&#160;</ins>' . $homePage['title'] . '</a>' . "\n";
        // add subpages
        $html .= self::getSubtree($navigation, 1);
        // end
        $html .= '        </li>' . "\n";
        $html .= '    </ul>' . "\n";
        $html .= '</div>' . "\n";
        // only show meta if needed
        if (BackendModel::get('fork.settings')->get('Pages', 'meta_navigation', false)) {
            // meta pages
            $html .= '<h4>' . \SpoonFilter::ucfirst(BL::lbl('Meta')) . '</h4>' . "\n";
            $html .= '<div class="clearfix" data-tree="meta">' . "\n";
            $html .= '    <ul>' . "\n";
            // are there any meta pages
            if (isset($navigation['meta'][0]) && !empty($navigation['meta'][0])) {
                // loop the items
                foreach ($navigation['meta'][0] as $page) {
                    // start
                    $html .= '        <li id="page-' . $page['page_id'] . '" rel="' . $page['tree_type'] . '">' . "\n";
                    // insert link
                    $html .= '            <a href="' . BackendModel::createURLForAction('Edit', null, null, array('id' => $page['page_id'])) . '"><ins>&#160;</ins>' . $page['navigation_title'] . '</a>' . "\n";
                    // insert subtree
                    $html .= self::getSubtree($navigation, $page['page_id']);
                    // end
                    $html .= '        </li>' . "\n";
                }
            }
            // end
            $html .= '    </ul>' . "\n";
            $html .= '</div>' . "\n";
        }
        // footer pages
        $html .= '<h4>' . \SpoonFilter::ucfirst(BL::lbl('Footer')) . '</h4>' . "\n";
        // start
        $html .= '<div class="clearfix" data-tree="footer">' . "\n";
        $html .= '    <ul>' . "\n";
        // are there any footer pages
        if (isset($navigation['footer'][0]) && !empty($navigation['footer'][0])) {
            // loop the items
            foreach ($navigation['footer'][0] as $page) {
                // start
                $html .= '        <li id="page-' . $page['page_id'] . '" rel="' . $page['tree_type'] . '">' . "\n";
                // insert link
                $html .= '            <a href="' . BackendModel::createURLForAction('Edit', null, null, array('id' => $page['page_id'])) . '"><ins>&#160;</ins>' . $page['navigation_title'] . '</a>' . "\n";
                // insert subtree
                $html .= self::getSubtree($navigation, $page['page_id']);
                // end
                $html .= '        </li>' . "\n";
            }
        }
        // end
        $html .= '    </ul>' . "\n";
        $html .= '</div>' . "\n";
        // are there any root pages
        if (isset($navigation['root'][0]) && !empty($navigation['root'][0])) {
            // meta pages
            $html .= '<h4>' . \SpoonFilter::ucfirst(BL::lbl('Root')) . '</h4>' . "\n";
            // start
            $html .= '<div class="clearfix" data-tree="root">' . "\n";
            $html .= '    <ul>' . "\n";
            // loop the items
            foreach ($navigation['root'][0] as $page) {
                // start
                $html .= '        <li id="page-' . $page['page_id'] . '" rel="' . $page['tree_type'] . '">' . "\n";
                // insert link
                $html .= '            <a href="' . BackendModel::createURLForAction('Edit', null, null, array('id' => $page['page_id'])) . '"><ins>&#160;</ins>' . $page['navigation_title'] . '</a>' . "\n";
                // insert subtree
                $html .= self::getSubtree($navigation, $page['page_id']);
                // end
                $html .= '        </li>' . "\n";
            }
            // end
            $html .= '    </ul>' . "\n";
            $html .= '</div>' . "\n";
        }
        // return
        return $html;
    }

Usage Example

Example #1
0
 /**
  * Parse
  */
 protected function parse()
 {
     parent::parse();
     // parse some variables
     $this->tpl->assign('templates', $this->templates);
     $this->tpl->assign('isGod', $this->isGod);
     $this->tpl->assign('positions', $this->positions);
     $this->tpl->assign('extrasData', json_encode(BackendExtensionsModel::getExtrasData()));
     $this->tpl->assign('extrasById', json_encode(BackendExtensionsModel::getExtras()));
     $this->tpl->assign('prefixURL', rtrim(BackendPagesModel::getFullURL(1), '/'));
     $this->tpl->assign('formErrors', (string) $this->frm->getErrors());
     $this->tpl->assign('showTags', $this->showTags());
     // get default template id
     $defaultTemplateId = $this->get('fork.settings')->get('Pages', 'default_template', 1);
     // assign template
     $this->tpl->assignArray($this->templates[$defaultTemplateId], 'template');
     // parse the form
     $this->frm->parse($this->tpl);
     // parse the tree
     $this->tpl->assign('tree', BackendPagesModel::getTreeHTML());
 }
All Usage Examples Of Backend\Modules\Pages\Engine\Model::getTreeHTML