CakePHP Element謫堺ス

繧ィ繝ャ繝。繝ウ繝医→縺ッ

View縺ョ荳驛ィ繧貞繧雁コ縺励※驛ィ蜩∝喧縺励◆繝輔ぃ繧、繝ォ
ctp繝輔ぃ繧、繝ォ縺ァ菫晏ュ倥@縲〃iew縺ォ邨縺ソ霎シ繧

騾壼クク

繧ィ繝ャ繝。繝ウ繝

窶サス/src/Template/Element/test.ctp
<div>
縲<?= echo('xxx'); ?>
</div>

繝薙Η繝シ

aaa
<?= $this->element('test'); ?>
bbb

邨先棡

aaa
xxx
bbb

繝代Φ縺上★繝ェ繧ケ繝医ョ繧ィ繝ャ繝。繝ウ繝亥喧シ繝繝ウ繝励Ξ繝シ繝亥喧

繝代Φ縺上★繝ェ繧ケ繝医↓縺、縺縺ヲ縺ッ縲CakePHP View謫堺ス Html繝倥Ν繝代シ/繝代Φ縺上★繝ェ繧ケ繝育函謌縲榊盾辣ァ
繝繝ウ繝励Ξ繝シ繝医↓縺、縺縺ヲ縺ッ縲CakePHP View謫堺ス/繝繝ウ繝励Ξ繝シ繝縲榊盾辣ァ

繧ィ繝ャ繝。繝ウ繝

窶サス/src/Template/Element/breadcrumbs.ctp
<div>
縲<?=
縲縲繝代Φ縺上★繝ェ繧ケ繝域怙蛻昴ョ繝壹シ繧ク
縲縲$this->Html->getCrumbs(' > ', [
縲縲縲縲'text' => '1繝壹シ繧ク逶ョ',
縲縲縲縲'url' => '/',
縲縲縲縲'escape' => false,
縲縲縲]);
縲?>
</div>

繧ウ繝ウ繝医Ο繝シ繝ゥ

$this->autoRender = true;
$this->viewBuilder()->layout('Tests');
$this->viewBuilder()->autoLayout(true);

窶サス/src/Template/Layout/tests.ctp
<html>
<body>
縲<?php echo $this->element('breadcrumbs'); ?>
縲<?= $this->fetch('content') ?>
</body>
</html>

繝薙Η繝シ

<?php
縲$this->Html->addCrumb('2繝壹シ繧ク逶ョ', ['controller' => 'ス', 'action' => 'ス']);
縲$this->Html->addCrumb('3繝壹シ繧ク逶ョ', '');
?>

邨先棡

1繝壹シ繧ク逶ョ > 2繝壹シ繧ク逶ョ > 3繝壹シ繧ク逶ョ

繧ォ繝繧エ繝ェ繝シCakePHP