PowerCMS Xで複数のモデルのデータを日付順に並べる

SQL


(SELECT 'blog' as model, `blog_id` as id, `blog_published_on` as published_on FROM `mt_blog`)
UNION
(SELECT 'event' as model, `event_id` as id, `event_published_on` as published_on FROM `mt_event`)
UNION
(SELECT 'report' as model, `report_id` as id, `report_published_on` as published_on FROM `mt_report`)
UNION
(SELECT 'recruitment' as model, `recruitment_id` as id, `recruitment_published_on` as published_on FROM `mt_recruitment`)
ORDER BY published_on DESC LIMIT 20;

PowerCMS Xの開発中に値を確認する

error_log("メッセージ\n", 3, $app->log_dir . DS . 'develop.log');
error_log($urlMapping->name . $app->ctx->stash('current_archive_title') . " ${objectCount}\n", 3, $app->log_dir . DS . 'develop.log');

配列がある時はprint_rを併用する。


error_log(print_r($terms, true) . "\n", 3, $app->log_dir . DS . 'develop.log');

管理画面のログも便利。


$app->log(['message' => 'Estraier Check', 'metadata' => $cmd]);

編集画面でモデルのオブジェクトを呼び出す

MTML


<mt:if name="request._model" eq="event">
<mt:var name="request.id" setvar="current_event_id" />
<mt:objectloop model="calendar" contents_id="$current_event_id" calendar_model="event" workspace_id="$workspace_id"><pre style="border: 1px solid #ccc; padding: 5px;">
  Start: <mt:var name="start_date" format_ts="Y年m月d日" escape />
  End: <mt:var name="end_date" format_ts="Y年m月d日" escape />
  FreqType: <mt:var name="freq_type" escape />
  FreqMonthInterval: <mt:var name="freq_type" escape />
  LedDate: <mt:var name="led_date" escape />
</pre></mt:objectloop>
</mt:if>