本文整理汇总了PHP中OutputPage::setHTMLTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP OutputPage::setHTMLTitle方法的具体用法?PHP OutputPage::setHTMLTitle怎么用?PHP OutputPage::setHTMLTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputPage
的用法示例。
在下文中一共展示了OutputPage::setHTMLTitle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insertTitle
public static function insertTitle(OutputPage &$out)
{
$title = $out->getHTMLTitle();
$title = str_replace(' - WebPlatform Docs', '', $title);
$page_path = explode('/', $title);
$topic = $page_path[0];
$pagename = array_pop($page_path);
$new_title = "{$pagename} · {$topic} · WPD · WebPlatform.org";
$out->setHTMLTitle($new_title);
return true;
}
示例2: modifyHTML
/**
* Modify the HTML to set the relevant tags to the specified values
*
* This method is called by the BeforePageDisplay hook
*
* @param OutputPage $out
*/
public static function modifyHTML($out)
{
//set title
if (!empty(self::$title)) {
switch (self::$title_mode) {
case 'append':
$title = $out->getPageTitle() . self::$title_separator . self::$title;
break;
case 'prepend':
$title = self::$title . self::$title_separator . $out->getPageTitle();
break;
case 'replace':
default:
$title = self::$title;
}
$out->setHTMLTitle($title);
$out->addMeta("twitter:title", $title);
$out->addHeadItem("og:title", "<meta property=\"og:title\" content=\"{$title}\" />" . "\n");
}
//set meta tags
if (!empty(self::$meta)) {
foreach (self::$meta as $name => $content) {
if ($name == 'description') {
$out->addMeta($name, $content);
$out->addMeta("twitter:description", $content);
$out->addHeadItem("og:description", Html::element('meta', array('property' => 'og:description', 'content' => $content)) . "\n");
} else {
$out->addMeta($name, $content);
}
}
}
//set property tags
if (!empty(self::$property)) {
foreach (self::$property as $property => $content) {
$out->addHeadItem("{$property}", Html::element('meta', array('property' => $property, 'content' => $content)) . "\n");
}
}
return true;
}