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

getFullURL() public static method

Get the full-URL for a given menuId
public static getFullURL ( integer $id ) : string
$id integer The Id of the page to get the URL for.
return string
    public static function getFullURL($id)
    {
        $keys = static::getCacheBuilder()->getKeys(BL::getWorkingLanguage());
        $hasMultiLanguages = BackendModel::getContainer()->getParameter('site.multilanguage');
        // available in generated file?
        if (isset($keys[$id])) {
            $url = $keys[$id];
        } elseif ($id == 0) {
            // parent id 0 hasn't an url
            $url = '/';
            // multilanguages?
            if ($hasMultiLanguages) {
                $url = '/' . BL::getWorkingLanguage();
            }
            // return the unique URL!
            return $url;
        } else {
            // not available
            return false;
        }
        // if the is available in multiple languages we should add the current lang
        if ($hasMultiLanguages) {
            $url = '/' . BL::getWorkingLanguage() . '/' . $url;
        } else {
            // just prepend with slash
            $url = '/' . $url;
        }
        // return the unique URL!
        return urldecode($url);
    }

Usage Example

Example #1
0
 /**
  * Parse
  */
 protected function parse()
 {
     parent::parse();
     // set
     $this->record['url'] = $this->meta->getURL();
     if ($this->id == 1) {
         $this->record['url'] = '';
     }
     // parse some variables
     $this->tpl->assign('item', $this->record);
     $this->tpl->assign('isGod', $this->isGod);
     $this->tpl->assign('templates', $this->templates);
     $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($this->record['parent_id']), '/'));
     $this->tpl->assign('formErrors', (string) $this->frm->getErrors());
     // init var
     $showDelete = true;
     // has children?
     if (BackendPagesModel::getFirstChildId($this->record['id']) !== false) {
         $showDelete = false;
     }
     if (!$this->record['delete_allowed']) {
         $showDelete = false;
     }
     // allowed?
     if (!BackendAuthentication::isAllowedAction('Delete', $this->getModule())) {
         $showDelete = false;
     }
     // show delete button
     $this->tpl->assign('showPagesDelete', $showDelete);
     // assign template
     $this->tpl->assignArray($this->templates[$this->record['template_id']], 'template');
     // parse datagrids
     $this->tpl->assign('revisions', $this->dgRevisions->getNumResults() != 0 ? $this->dgRevisions->getContent() : false);
     $this->tpl->assign('drafts', $this->dgDrafts->getNumResults() != 0 ? $this->dgDrafts->getContent() : false);
     // parse the tree
     $this->tpl->assign('tree', BackendPagesModel::getTreeHTML());
 }
All Usage Examples Of Backend\Modules\Pages\Engine\Model::getFullURL