ZendFrameworkビュースクリプトでのbodyタグ
以下のように記述するとcssで装飾しやすい気がする。
■コントローラ
public function init(){
$this->_view->module = $this->_getParam('module');
$this->_view->controller = $this->_getParam('controller');
$this->_view->action = $this->_getParam('action');
}
■ビュー
<body class="<?php print($this->controller); ?>" id="<?php print($this->controller); ?>_<?php print($this->action); ?>">
ちなみに以下のようになっている。
print($this->module);//モジュール名 print($this->controller);//コントローラ名 print($this->action);//アクション名
出力例
<body class="category" id="category_register">
参考
以下の例の場合を考えてみる。
<body class="<?php print($this->module); ?> <?php print($this->controller); ?> <?php print($this->action); ?>">
出力例
<body class="category" id="category_register">
一見素晴らしいが、IEが以下のセレクタに対応していないため使用できない。
body.admin.category.register {
background-color: red;
}
body.register {
background-color: blue;
}
上述のように記述するとIE6のみbodyの背景色がblueになるはずだ。
TrackBack URL :
Comments (0)
コメントはまだありません»
コメントはまだありません。
この投稿へのコメントの RSS フィード。TrackBack URL
コメントする