Frontend\Core\Engine\Header::setPageTitle PHP Method

setPageTitle() public method

Set the page title
public setPageTitle ( string $value, boolean $overwrite = false )
$value string The page title to be set or to be prepended.
$overwrite boolean Should the existing page title be overwritten?
    public function setPageTitle($value, $overwrite = false)
    {
        $value = trim((string) $value);
        $overwrite = (bool) $overwrite;
        // overwrite? reset the current value
        if ($overwrite) {
            $this->pageTitle = $value;
        } else {
            // empty value given?
            if (empty($value)) {
                $this->pageTitle = $this->get('fork.settings')->get('Core', 'site_title_' . LANGUAGE, SITE_DEFAULT_TITLE);
            } else {
                // if the current page title is empty we should add the site title
                if ($this->pageTitle == '') {
                    $this->pageTitle = $value . ' -  ' . $this->get('fork.settings')->get('Core', 'site_title_' . LANGUAGE, SITE_DEFAULT_TITLE);
                } else {
                    // prepend the value to the current page title
                    $this->pageTitle = $value . ' - ' . $this->pageTitle;
                }
            }
        }
    }

Usage Example

示例#1
0
 /**
  * Processes the page
  */
 protected function processPage()
 {
     // set pageTitle
     $this->header->setPageTitle($this->record['meta_title'], (bool) ($this->record['meta_title_overwrite'] == 'Y'));
     // set meta-data
     $this->header->addMetaDescription($this->record['meta_description'], (bool) ($this->record['meta_description_overwrite'] == 'Y'));
     $this->header->addMetaKeywords($this->record['meta_keywords'], $this->record['meta_keywords_overwrite'] == 'Y');
     $this->header->setMetaCustom($this->record['meta_custom']);
     // advanced SEO-attributes
     if (isset($this->record['meta_data']['seo_index'])) {
         $this->header->addMetaData(array('name' => 'robots', 'content' => $this->record['meta_data']['seo_index']));
     }
     if (isset($this->record['meta_data']['seo_follow'])) {
         $this->header->addMetaData(array('name' => 'robots', 'content' => $this->record['meta_data']['seo_follow']));
     }
     // create navigation instance
     new Navigation($this->getKernel());
     // assign content
     $pageInfo = Navigation::getPageInfo($this->record['id']);
     $this->record['has_children'] = $pageInfo['has_children'];
     $this->tpl->assign('page', $this->record);
     // set template path
     $this->templatePath = FRONTEND_PATH . '/' . $this->record['template_path'];
     // loop blocks
     foreach ($this->record['positions'] as $position => &$blocks) {
         // position not known in template = skip it
         if (!in_array($position, $this->record['template_data']['names'])) {
             continue;
         }
         // loop blocks in position
         foreach ($blocks as $index => &$block) {
             // an extra
             if ($block['extra_id'] !== null) {
                 // block
                 if ($block['extra_type'] == 'block') {
                     // create new instance
                     $extra = new FrontendBlockExtra($this->getKernel(), $block['extra_module'], $block['extra_action'], $block['extra_data']);
                     if (extension_loaded('newrelic')) {
                         newrelic_name_transaction($block['extra_module'] . '::' . $block['extra_action']);
                     }
                 } else {
                     // widget
                     $extra = new FrontendBlockWidget($this->getKernel(), $block['extra_module'], $block['extra_action'], $block['extra_data']);
                 }
                 // add to list of extras
                 $block = array('extra' => $extra);
                 // add to list of extras to parse
                 $this->extras[] = $extra;
             } else {
                 // the block only contains HTML
                 $block = array('blockIsEditor' => true, 'blockContent' => $block['html']);
                 // Maintain backwards compatibility
                 $block['blockIsHTML'] = $block['blockIsEditor'];
             }
         }
     }
 }
All Usage Examples Of Frontend\Core\Engine\Header::setPageTitle