LoginSignup
1
0

More than 5 years have passed since last update.

elementExists()でファイルがある時だけelementを出力する #CakePHP

Posted at

CakePHP 2.3以降

element.ctpの有無をelementExists()でチェック、
ファイルがあれば出力、
表示したくない/必要なくなった後はelement.ctpを削除し出力しない利用方法。

Viewの.ctpファイル内、

<?php if ($this->elementExists('element')): ?>
<?php echo $this->element('element'); ?>
<?php endif; ?>

参考

1
0
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
1
0