MTカスタマイズ カスタムフィールドの検索 - グレヌデサ La graine du dessin
Coding

MTカスタマイズ カスタムフィールドの検索

MT4から追加された機能に、カスタムフィールドという独自の入力項目を追加できる便利な機能があります。
ですが検索フォームを使ってカスタムフィールドの値を検索できませんでした。
今回はそれに加えて、カテゴリ検索のAnd検索をする方法を紹介します。
※下記はMT5での解説となります。


11604_01.jpg
こんな感じのAnd検索が可能です


1.プラグインを追加する

まずTechnology on Informationさんのプラグインを利用します。
それぞれダウンロードしてインストールしてください。
■カスタムフィールドの内容を対象にして検索:CustomFieldsSearch
■カテゴリー情報による検索:CategorySearch

どちらも修正BSDライセンスですが、これはかなり緩いライセンス形態で、商用利用も改変もしてよいですが、かわりに無保証で著作権の表示が必要というライセンスです。
ソースの上部に著作権表示しておけばOKじゃないでしょうか。


2.ソースを作成する



○カスタムフィールドサーチを有効にするかどうか。
value="1" これでカスタムフィールド検索が有効になります。
<input type="hidden" name="CustomFieldsSearch" value="1" />

○検索対象を指定します。
value="entry"でブログ記事が検索対象になります。 
value="page"でウェブページが検索対象になります。 
<input type="hidden" name="CustomFieldsSearchClassType" value="entry" />

○カスタムフィールドでないカラムを無視する場合に指定します。
これにより余計な検索をせずに若干結果表示が速くなります。
<input type="hidden" name="CustomFieldsSearchIgnore" value="EntryTitle" />
<input type="hidden" name="CustomFieldsSearchIgnore" value="EntryBody" />
<input type="hidden" name="CustomFieldsSearchIgnore" value="EntryMore" />
<input type="hidden" name="CustomFieldsSearchIgnore" value="EntryKeywords" />

○カテゴリサーチを有効にするかどうか。
value="1" でカテゴリ検索が有効になります。
<input type="hidden" name="CategorySearch" value="1" />
<input type="hidden" name="CategorySearchSets" value="1" /> 

○カスタムフィールド検索
指定したキーと値で絞込みを行います(value="カスタムフィールドタグ:○○○")
<select name="CustomFieldsSearchFieldLike">
<option selected="selected">▼エリアを選んでください</option>
<option value="area:北海道">北海道</option>
<option value="area:青森県">青森県</option>
<option value="area:岩手県">岩手県</option>

○カテゴリ検索
カテゴリ選択用がプルダウンの場合は
「select name="1"」に設定すれば有効になるみたいです。
<select name="1" id="select_category">
(takanosuke)
New Entries
TOP
Old Entries

Webトレンド情報局とは

クリエイティブグループスタッフがお送りする、Webデザイナーのための知識とTIPS。 PhotoShopの便利な豆知識や、CSSのお困り解決、デザイン概論などなど。
【隔週木曜日更新】

運営会社:株式会社ジーピーオンライン

RSSを購読する

Monthly Archive


Warning: MagpieRSS: Failed to fetch http://lab.gpol.co.jp/trend/atom.xml and cache is off in /usr/home/aa218u55sc/html/magpierss/rss_fetch.inc on line 240

Warning: Invalid argument supplied for foreach() in /usr/home/aa218u55sc/html/graine/footerrss.php on line 36

Warning: MagpieRSS: Failed to fetch http://lab.gpol.co.jp/tsubo/atom.xml and cache is off in /usr/home/aa218u55sc/html/magpierss/rss_fetch.inc on line 240

Warning: Invalid argument supplied for foreach() in /usr/home/aa218u55sc/html/graine/footerrss.php on line 36

Warning: MagpieRSS: Failed to parse RSS file. (Mismatched tag at line 89, column 8) in /usr/home/aa218u55sc/html/magpierss/rss_fetch.inc on line 240

Warning: Invalid argument supplied for foreach() in /usr/home/aa218u55sc/html/graine/footerrss.php on line 36