指定:MODx 1.0.0
必要:次の形式でニュースのリストを表示します。
25.08.09
> 2 25
> 1 25
24.08.09
> 24
Dittoの一部を書き換えずにこれを行うことは可能ですか?
オプション1-
エクステンダー 。 コードをファイル
asset / snippets / ditto / extenders / dateGroup.extender.inc.phpに保存します<?php
global $dateSource, $dateFormat;
$dateSource = isset($dateSource) ? $dateSource : "createdon";
$placeholders['groupDate'] = array(array($dateSource, "*"), "getGroupDate", $dateSource);
$dateFormat = isset($dateFormat)? $dateFormat : '%d.%m.%y';
if (!function_exists("getGroupDate")) {
function getGroupDate($resource) {
static $date = '', $id = '';
global $dateSource, $dateFormat;
if ($date !== strftime('%d.%m.%y', $resource[$dateSource]) || $id == $resource['docid']) {
$id = $resource['id'];
$date = strftime('%d.%m.%y', $resource[$dateSource]);
return strftime($dateFormat, $resource[$dateSource]);
} else {
return false;
}
}
}
?>
次に、ditto呼び出しのパラメーターで
PHx -'&phx = `1``を有効にします。リストの各ニュース(&tpl)を表示するチャンクで、次のように記述します。
[+groupDate:isnot=``:then=`<p class='news_date'>[+groupDate+]</p>`+]
<p class='news_item'>
<span class='title'><a href='[~[+id+]~]'>[+pagetitle+]</a></span>
[+introtext:isnot=``:then=`<br /><span class='description'>[+introtext+]</span>`+]
</p>
オプション2、Dittoなし(
fuzzyで推奨)
-modx.ru/blog/modx-adding-articles