2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

a-blog cmsで、URLクエリパラメータをグローバル変数にする

Last updated at Posted at 2018-09-17

URLに付与されたクエリパラメータを、個別にグローバル変数にする。

参考:フック処理

まず、config.server.php の HOOK_ENABLE を1にしてフック拡張を有効にする。

define('HOOK_ENABLE', 1);

次に、a-blog cmsインストールディレクトリのextension/acms/Hook.phpを開いて、「グローバル変数の拡張」の部分を編集する。

public function extendsGlobalVars(&$globalVars)
{
	$url_params = $_SERVER['QUERY_STRING'];//URLクエリパラメータの取得
	parse_str($url_params, $param_array);//配列に
	foreach ($param_array as $key => $value) {//キーを変数名にして値を設定
		$globalVars -> set(strtoupper($key), $value);
	}
}
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?