====== mini tips ======
[[web:modx:revolution|MODx Revolution]]の独立したページを作るほどではないけれど、メモっておきたいTipsなど。
===== MODxのバージョン =====
SELECT value FROM modx_system_settings WHERE modx_system_settings.key = 'settings_version';
$version = $modx->getOption('settings_version');
OR
[[++settings_version]]
===== chunkとプレースホルダ =====
$modx->setPlaceholder('プレースホルダ名', $value);
$output = $modx->getChunk('chunk name');
===== 自分自身へのLink =====
[[~[[*id]]]]
===== includeファイルでのmodxオブジェクトの使用 =====
この一文を入れておけば使用可能。
global $modx;
===== リダイレクト =====
ID 34のページにリダイレクトする場合。
$url = $modx->makeUrl(34);
$modx->sendRedirect($url);
HTTPレスポンスヘッダで、「301 Moved Permanently」(永久的な移転)を返す場合。
$modx->sendRedirect('http://example.com',array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
==== 参考 ====
[[http://rtfm.modx.com/display/revolution20/modX.sendRedirect]]\\
[[http://api.modxcms.com/modx/modX.html#sendRedirect|API Doc]]
===== ログイン中のユーザID、ユーザ名の表示 =====
[[+modx.user.id]] - Prints the ID
[[+modx.user.username]] - Prints the username