これを達成するには、いくつかの作業が必要ですが、あまり難しくありません。
まず、新しいテンプレート変数を作成します。任意の名前を付けてください(例:list_children
)。そして、入力オプション]タブに移動し、Checkbox
に入力タイプを設定し、入力オプション値の下に次のように入力します。
@eval return $modx->runSnippet('list_children');
ゴー出力オプション]タブにし、出力タイプのドロップダウンに区切り文字を選択します。デリミタのテキストボックスには、単一のカンマ,
を記述します。選択したテンプレートにテンプレート変数を適用して保存します。
新規、新しいスニペットを作成します。このlist_children
と名前を付けるか、eval式を変更して呼び出します。このスニペットで
、次のように入力します。
<?php
$c = $modx->newQuery('modResource');
$c->where(array(
'parent' => 2, // Id to fetch children from
'published' => 1, // Remove this line if you also want to include unpublished resources
'deleted' => 0 // Remove this line if you also want resources that are marked for deletion
));
$c->sortby('menuindex', 'ASC');
$collection = $modx->getCollection('modResource', $c);
$output = array();
foreach ($collection as $v) {
$output[] = $v->get('pagetitle') . '==' . $v->get('id');
}
return implode('||', $output);