Created
October 15, 2012 00:55
-
-
Save atsu666/3890331 to your computer and use it in GitHub Desktop.
#ablogcms エントリ作成時のPOSTデータを編集するサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* POSTモジュール処理前 | |
* $thisModuleのプロパティを参照・操作するなど | |
* | |
* @param ACMS_POST $thisModule | |
*/ | |
public function beforePostFire($thisModule) | |
{ | |
$moduleName = get_class($thisModule); | |
// 新規エントリ作成時 | |
if ( $moduleName == 'ACMS_POST_Entry_Insert' ) { | |
$Post = $thisModule->Post; // Postデータを取得 | |
$code = $Post->get('code'); // エントリコードを取得 | |
// var_dump($Post); // Postの中身を確認 | |
// エントリコードが空だった場合 | |
if ( empty($code) ) { | |
$DB = DB::singleton(dsn()); | |
$next_id = $DB->query(SQL::currval('entry_id', dsn()), 'seq') + 1; | |
$cid = $Post->get('category_id'); | |
// カテゴリが指定してある場合、カテゴリコードをエントリコードに設定 | |
if ( !empty($cid) ) { | |
$ccode = ACMS_RAM::categoryCode($cid); | |
$code = $ccode.'_'.$next_id.'html'; | |
} else { | |
$code = 'entry_'.$next_id.'html'; | |
} | |
$Post->set('code', $code); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment