Context::addHtmlHeader($header)
정의 위치
- ./classes/context/Context.class.php
정의 내용
/**
* Add html code before </head>
*
* @param string $header add html code before </head>.
* @return void
*/
function addHtmlHeader($header)
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$self->html_header .= "\n" . $header;
}
* Add html code before </head>
*
* @param string $header add html code before </head>.
* @return void
*/
function addHtmlHeader($header)
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$self->html_header .= "\n" . $header;
}
파라메터
- string $header : 생성될 HTML 문서 내용 중 <head> </head>에 추가할 문자열입니다.
용도
- 기본으로 생성되지 않는 스크립트 추가
- 자바스크립트를 HTML 에 직접 포함하거나 CSS 를 직접 포함할 때 주로 이용하게 된다. <meta> 태그를 입력하는 용도로 이용할 수도 있다. <meta> 의 경우 Context::addMetaTag() 메소드를 이용할 수도 있지만, 이 메소드로 추가한 메타 태그는 현재(XE Core 1.8.7 기준) mobile 페이지에서 적용되고 있지 않다.
예제
- ./addons/blogapi/blogapi.addon.php 내용 중
-
// Insert a rsd tag when called_position is after_module_proc
if($called_position == 'after_module_proc')
{
// Create rsd address of the current module
$site_module_info = Context::get('site_module_info');
$rsd_url = getFullSiteUrl($site_module_info->domain, '', 'mid', $this->module_info->mid, 'act', 'api');
// Insert rsd tag into the header
Context::addHtmlHeader(" " . '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . $rsd_url . '" />');
}
-
- ./addons/openid_deligation_id/openid_deligation_id.addon.php 내용 중
-
$header_script = sprintf(
'<link rel="openid.server" href="%s" />' . "\n" .
'<link rel="openid.delegate" href="%s" />' . "\n" .
'<meta http-equiv="X-XRDS-Location" content="%s" />',
$addon_info->server,
$addon_info->delegate,
$addon_info->xrds
);
Context::addHtmlHeader($header_script);
-
- ./modules/editor/editor.controller.php 내용 중 triggerEditorComponentCompile 메소드 중
-
$content_font = $editor_config->content_font;
$content_font_size = $editor_config->content_font_size;
if($content_font || $content_font_size)
{
$buff = array();
$buff[] = '<style> .xe_content { ';
if($content_font) $buff[] = 'font-family:'.$content_font.';';
if($content_font_size) $buff[] = 'font-size:'.$content_font_size.';';
$buff[] = ' }</style>';
Context::addHtmlHeader(implode('', $buff));
}
-
댓글 1
제가 위젯에서 사용해보려고 하는데, 위젯을 출력하고 위젯 하단에 텍스트를 출력하려고 하는데..
그런 함수는 없나요? addBodyHeader나 addHTmlFooter 같이 문서의 상단이나 하단에 출력하는 건 있던데, 출력하는 위젯 안에 바로 출력해주는 건 없더군요. 제가 확인해본 게 맞나요.
Context::addHtmlHeader()
Context::clearHtmlHeader()
Context::getHtmlHeader()
Context::addBodyClass()
Context::getBodyClass()
Context::addBodyHeader()
Context::getBodyHeader()
Context::getBodyHeader()
Context::addHtmlFooter()
Context::getHtmlFooter()
Context::getConfigFile()
Context::getFTPConfigFile()
Context::isInstalled()
Context::transContent()
Context::isAllowRewrite()
Context::pathToUrl()
Context::getMetaTag()
Context::addMetaTag()