Mais conteúdo relacionado
Semelhante a Movable Type PHP API について - MTCafe Saitama 2013 (20)
Movable Type PHP API について - MTCafe Saitama 2013
- 6. ダイナミックパブリッシングの処理 (1)
• 404 エラーをフックして処理を実行
DirectoryIndex index.php index.html index.htm /5.2.7/01/02/mtview.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)(?.*)?$ /5.2.7/01/02/mtview.php$2 [L,QSA]
- 7. ダイナミックパブリッシングの処理 (2)
• mtview.php
• リクエストからテンプレート情報取得
• Smarty を利用して表示
<?php
include('/Users/taketoshi/Sites/5.2.7/mt/php/mt.php');
$mt = MT::get_instance(3, '/Users/taketoshi/Sites/5.2.7/mt/mt-config.cgi');
$mt->view();
?>
- 8. ダイナミックパブリッシングの処理 (3)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" id="sixapart-standard">
<head>
<$mt:Include module="HTMLヘッダー"$>
<title><$mt:BlogName encode_html="1"$>: <$mt:ArchiveTitle$>アーカイブ</
title>
- 9. ダイナミックパブリッシングの処理 (4)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" id="sixapart-standard">
<head>
<?php $this->_tag_stack[] = array("mtinclude", array (
'module' => 'HTMLヘッダー',
)); echo multiblog_MTInclude(array('module' => "HTMLヘッダー"), $this);
array_pop($this->_tag_stack); ?>
<title><?php $this->_tag_stack[] = array("mtblogname", array (
'encode_html' => '1',
)); echo ((is_array($_tmp=smarty_function_mtblogname(array(), $this))) ?
$this->_run_mod_handler('encode_html', true, $_tmp, '1') :
smarty_modifier_encode_html($_tmp, '1')); array_pop($this->_tag_stack); ?>
: <?php $this->_tag_stack[] = array("mtarchivetitle", array (
)); echo smarty_function_mtarchivetitle(array(), $this); array_pop($this-
>_tag_stack); ?>
アーカイブ</title>
- 11. PHP からの利用<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="<mt:PublishCharset />">
<title>#02</title>
</head>
<body>
<p>Display Name of author_id = 1</p>
<?php
$MT_PHP = '<mt:CGIServerPath />/php/mt.php';
$MT_CFG = '<mt:ConfigFile />';
include( $MT_PHP );
$mt = MT::get_instance();
require_once('<mt:CGIServerPath />/php/lib/class.mt_author.php');
$author = new Author;
if ( $author->Load('author_id=1') ) {
echo " <p>Display Name: ".$author->nickname."</p>";
}
?>
</body>
</html>
- 12. Movable Typa PHP API
• PHP から MT オブジェクトへのアクセス
• get_instance 後にクラスを require
• オブジェクトを取得するだけで OK
• テンプレートデータを利用するために
Smarty を利用して出力