[MovableType]出力ファイルのパーミッションを755へ
mt-config.cgiに下記を追記
DirUmask 0022 HTMLPerms 0755 UploadPerms 0755
mt-config.cgiに下記を追記
DirUmask 0022 HTMLPerms 0755 UploadPerms 0755
x
同じ日付の記事1つ目:1
同じ日付の記事2つ目:2
<mt:For regex_replace="/[\ \t\r\n]/mg",""> <mt:EntryDate format="%Y%m%d" setvar="current_entry_date" /> <mt:EntryID setvar="current_entry_id" /> <mt:EntryBlogID setvar="blog_id"/> <mt:Blogs blog_ids="$blog_id"> <mt:Var name="count" value="1"/> <mt:Var name="no" value="1"/> <mt:Entries lastn="0" sort_by="authored_on" sort_order="ascend"> <mt:EntryDate format="%Y%m%d" setvar="entry_date" /> <mt:EntryID setvar="entry_id" /> <mt:If name="entry_date" eq="$current_entry_date"> <mt:If name="entry_id" eq="$current_entry_id"><mt:Var name="no" value="$count"/></mt:If> <mt:SetVar name="count" op="++"/> </mt:If> </mt:Entries> </mt:Blogs> <mt:Var name="current_entry_date"/>_<mt:Var name="no"/>.html</mt:For>
phpでMTのデータ取得
public $basepath = ''; public $cfg_file = 'mt-config.cgi'; public $blog_id = null; public $mt; public function __construct($blog_id = null) { $this->basepath = dirname(dirname(dirname(__FILE__))) . '/mt'; set_include_path(get_include_path() . PATH_SEPARATOR . $this->basepath . '/php' . PATH_SEPARATOR . $this->basepath . '/php/extlib' . PATH_SEPARATOR . $this->basepath . '/MT/php/lib'); require_once('mt.php'); $this->init_mt($blog_id); } public function init_mt($blog_id = null) { $this->blog_id = $blog_id; $this->mt = MT::get_instance($blog_id, $this->cfg_file); } public function get_custom_fields_by_entry_id($entry_id) { $sql[] = "SELECT"; $sql[] = "entry_meta_entry_id as entry_id,"; $sql[] = "REPLACE(entry_meta_type,'field.','') as name,"; $sql[] = "(CASE"; $sql[] = "WHEN entry_meta_vchar IS NOT NULL THEN entry_meta_vchar"; $sql[] = "WHEN entry_meta_vchar_idx IS NOT NULL THEN entry_meta_vchar_idx"; $sql[] = "WHEN entry_meta_vdatetime IS NOT NULL THEN entry_meta_vdatetime"; $sql[] = "WHEN entry_meta_vdatetime_idx IS NOT NULL THEN entry_meta_vdatetime_idx"; $sql[] = "WHEN entry_meta_vinteger IS NOT NULL THEN entry_meta_vinteger"; $sql[] = "WHEN entry_meta_vinteger_idx IS NOT NULL THEN entry_meta_vinteger_idx"; $sql[] = "WHEN entry_meta_vfloat IS NOT NULL THEN entry_meta_vfloat"; $sql[] = "WHEN entry_meta_vfloat_idx IS NOT NULL THEN entry_meta_vfloat_idx"; $sql[] = "WHEN entry_meta_vblob IS NOT NULL THEN entry_meta_vblob"; $sql[] = "WHEN entry_meta_vclob IS NOT NULL THEN entry_meta_vclob"; $sql[] = "ELSE NULL END) as value"; $sql[] = "FROM mt_entry_meta WHERE entry_meta_entry_id " . $this->_get_sql_for_in($entry_id,true); $sql = implode(' ',$sql); $records = $this->mt->db()->execute($sql); $records = $this->get_array_by_records($records); $tmp = array(); if(!is_array($entry_id)){ foreach ($records as $rec) { $tmp[$rec['name']] = $rec['value']; } return $tmp; } return $records; } protected function _get_sql_for_in($values, $is_number = false) { if ($is_number) return is_array($values) && 1 < count($values) ? "IN (" . implode(",", $values) . ")" : (is_array($values) ? "= {$values[0]}" : "= $values"); return is_array($values) && 1 < count($values) ? "IN ('" . implode("','", $values) . "')" : (is_array($values) ? "= '{$values[0]}'" : "= '$values'"); } public function get_array_by_records($records) { $result = array(); if (!$records){ }else { while ($item = $records->fetchRow()) { $result[] = $item; } } return $result; }
MovableType on windows xampp
■ メール送信チェックをする場合は C:\xampp\sendmail\sendmail.iniの下記の部分を設定しておく auth_username=xxxxx.xxxx auth_password=xxxxxxx ■フォルダ構成 /mt-static /cgi-bin/mt ■アクセス http://yourdomain/cgi-bin/mt/ ■ MovableTypeへサインイン ■ スタティックウェブパス /mt-static スタティックファイルパス C:\xampp\htdocs\mt_test\mt-static ■ システムチェック 次へ ■ ActivePerlインストール インストール先C:\xampp\perl C:\xampp\perlに元々あったファイルは削除 ■ コマンドプロンプト ppm Enter 設定 Areas Prefix:C:\xampp\perをチェック > ok dbd-mysql インストール ■ sendmailパス C:\xampp\sendmail\sendmail.exe ■ テンポラリーディレクトリ C:\xampp\tmp
フィールド名を変数で指定
カスタムフィールド
CFEntryDataAddress1~CFEntryDataAddress10
CFEntryDataDetailImage1~CFEntryDataDetailImage10
を表示
<MTFor var="x" from="1" to="10"> <MTIgnore>テキストの時</MTIgnore> <MTSetVarBlock name="_CFEntryDataAddress"><MTCFEntryDataAddress<MTVar name="x">></MTSetVarBlock> <MTSetVarBlock name="_CFEntryDataAddressValue"><MTVar name="_CFEntryDataAddress" decode_html="1" mteval="1"></MTSetVarBlock> <MTIf name="_CFEntryDataAddressValue" ne=""> <MTVar name="_CFEntryDataAddressValue" encode_html="1"> </MTIf> <MTIgnore>画像の時</MTIgnore> <MTSetVarBlock name="_CFEntryDataDetailImage"><MTCFEntryDataDetailImage<MTVar name="x">></MTSetVarBlock> <MTSetVarBlock name="_CFEntryDataDetailImageValue"><MTVar name="_CFEntryDataDetailImage" decode_html="1" mteval="1"></MTSetVarBlock> <MTSetVar name="_CFEntryDataDetailImageAsset" value=""> <MTIf name="_CFEntryDataDetailImageValue" ne=""> <MTSetVarBlock name="_CFEntryDataDetailImageAsset"> <MTCFEntryDataDetailImage<MTVar name="x">Asset> <img src="<MTAssetThumbnailURL width="450" force="1">"> </MTCFEntryDataDetailImage<MTVar name="x">Asset> </MTSetVarBlock> </MTIf> <MTIf name="_CFEntryDataDetailImageAsset" ne=""> <MTVar name="_CFEntryDataDetailImageAsset" decode_html="1" mteval="1"> </MTIf> </MTFor>
カスタムフィールドのPDFへのリンク
<MTIf tag="CFEntryDataPdf"> <MTCFEntryDataPdfAsset> <a href="<MTAssetURL>" target="_blank">donwload pdf</a> </MTCFEntryDataPdfAsset> </MTIf>
プラグイン「PageBute」でページネーションテンプレ
<MTIgnore>1ページに表示する記事数</MTIgnore> <MTSetVar name="per_page" value="12"> <mt:Entries lastn="0" sort_by="authored_on" sort_order="descend"> <mt:EntriesCount setvar="entries_count"/> </mt:Entries> <mt:If name="entries_count" gt="$per_page"> <ul> <MTPagination> <MTPaginationHeader> <MTIfPaginationFirst> <li class="prev"><a href="<MTPaginationPrev regex_replace="/index\.html$/","">">前へ</a></li> <MTElse> <MTignore>最初のページの時</MTignore> <li class="prev"><span>前へ</span></li> </MTIfPaginationFirst> </MTPaginationHeader> <MTIfPaginationCurrent> <MTignore>現在のページ</MTignore> <li class="is_active"><MTPaginationLink element="number"></li> <MTElse> <MTignore>それ以外(遷移用のリンクあり)</MTignore> <li><a href="<MTPaginationLink regex_replace="/index\.html$/","">"><MTPaginationLink element="number"></a></li> </MTIfPaginationCurrent> <MTPaginationFooter> <MTIfPaginationLast> <li class="next"><a href="<MTPaginationNext>">次へ</a></li> <MTElse> <MTignore>最後のページの時</MTignore> <li class="next"><span>次へ</span></li> </MTIfPaginationLast> </MTPaginationFooter> </MTPagination> </ul> </mt:If>
文字列分割プラグイン「Split」
<MTSetVarBlock name="blog_path"><MTCanonicalURL with_index="1"></MTSetVarBlock> <MTIgnore>プラグイン「Split」の機能</MTIgnore> <MTVar name="blog_path" split="/" setvar="bp_parts"> <MTSetVarBlock name="filename"><MTVar name="pop(bp_parts)"></MTSetVarBlock>
ページ分割プラグイン「PageBute」
http://www.mtcms.jp/movabletype-blog/plugins/pagebute/
<MTIgnore>1ページに表示する記事数</MTIgnore> <MTSetVar name="per_page" value="6"> <MTIgnore>プラグイン「PageBute」の機能</MTIgnore> <MTPageContents count="$per_page"> <MTEntries sort_by="authored_on" sort_order="descend"> <p><MTEntryTitle trim_to="30+..." encode_html="1"></p> <MTPageSeparator> </MTEntries> </MTPageContents>
本文のpタグ削除。でも改行はさせる。
<MTEntryBody regex_replace="/<br />/g","<br />\n" regex_replace="/<p>|</p>/g","" nl2br="xhtml">