はじめに
2011/
今回は、
インストール
ご想像のとおり、
ドキュメント中にも記されているよう、
簡単なテスト
まずはわかりやすい例として、
タイトル | 検索 |
---|---|
エイリアス | search |
リソースコンテンツ | [[!SimpleSearchForm]] |
これだけで、

チャンクを用いた高度なデザイン
前述の例では、
今回はこのようなフォームを実現するための方法も簡単に紹介しておきます。
まず、
[[!SimpleSearchForm? &landing=`20` &tpl=`my_search`]]
tpl=`my_
また、
<script type="text/javascript">
<!--
function erase_words(obj){
if(obj.value==obj.defaultValue){
obj.value="";
obj.style.color="#000";
}
}
function put_words(obj){
if(obj.value==""){
obj.value=obj.defaultValue;
obj.style.color="#999";
}
}
//-->
</script>
<form action="[[~[[+landing]]]]"method="[[+method]]">
<input type="text"id="keywords4"name="[[+searchIndex]]"value="検索キーワードを入力"size="20"onFocus="erase_words(this)"onBlur="put_words(this)"style="color: #999;"/>
<input type="hidden"name="id"value="[[+landing]]"/>
</form>
以上により、

検索結果表示用のリソースは次のように作成します。今回も結果表示のデザインを変更するため、
タイトル | 検索結果 |
---|---|
エイリアス | search-result |
メニューに表示しない | チェック |
リソースコンテンツ | <p>[[!SimpleSearch? &containerTpl=`my_ |
<p>[[+resultInfo]]</p>
[[+results]]
検索結果[[+paging]]
以上で準備完了です。適当なページから検索を行ってみてください。

どうでしょうか?
日本語表示
ちょっと待ってください。無事検索はできるようになりましたが、
1 Results found for "modx"
のような英語表記になっています。
スニペットの作者は日本人とは限らないため、
MODxにはこのような英語表示を多言語表示するための仕組みが備わっています。それがこれまでも何度も出てきたLexicon
LinuxやUNIXに少し詳しい方であれば、
たとえば、
#: gnu/argmatch.c:136
#, c-format
msgid "ambiguous argument %s for %s"
msgstr "引数 %s は %s に対してあいまいです"
MODxでも、
# find /var/www/html/core/components/simplesearch/lexicon
/var/www/html/core/components/simplesearch/lexicon
/var/www/html/core/components/simplesearch/lexicon/en
/var/www/html/core/components/simplesearch/lexicon/en/properties.inc.php
/var/www/html/core/components/simplesearch/lexicon/en/default.inc.php
/var/www/html/core/components/simplesearch/lexicon/fr
/var/www/html/core/components/simplesearch/lexicon/fr/properties.inc.php
/var/www/html/core/components/simplesearch/lexicon/fr/default.inc.php
/var/www/html/core/components/simplesearch/lexicon/nl
/var/www/html/core/components/simplesearch/lexicon/nl/properties.inc.php
/var/www/html/core/components/simplesearch/lexicon/nl/default.inc.php
/var/www/html/core/components/simplesearch/lexicon/de
/var/www/html/core/components/simplesearch/lexicon/de/properties.inc.php
/var/www/html/core/components/simplesearch/lexicon/de/default.inc.php
/var/www/html/core/components/simplesearch/lexicon/ru
/var/www/html/core/components/simplesearch/lexicon/ru/properties.inc.php
/var/www/html/core/components/simplesearch/lexicon/ru/default.inc.php
たとえば、
$_lang['sisea.results_found'] = '[[+count]] Results found for "[[+text]]"';
$_lang['sisea.result_pages'] = 'Result pages:';
現時点でjaディレクトリは用意されていませんので、
日本語用語彙フォルダの準備
では、
# cd /var/www/html/core/components/simplesearch/lexicon # cp -a en ja
あとは、
試しに、
[[+count]] Results found for "[[+text]]"
から
"[[+text]]"というキーワードは[[+count]]件見つかりました。
に変更してみます。

次に、

さて、
答えは、
最後に
今回SimpleSearchスニペットを紹介した理由は、
次回はこのあたりを詳しく見ていき、