I'm currently trying to use cakephp to create my own small CMS in php. So that it should be easy to modify the website. First of all im not a web programmer this is just for spare time.
I have a controller Button and a button can have multiple categories. so im trying to load this into the default.ctp so that this menu will be loaded for every page.
default.ctp code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
<?php __('eg'); ?>
<?php echo $title_for_layout; ?>
</title>
<?php
echo $this->Html->css('cake.generic.style');
echo $scripts_for_layout;
?>
</head>
<body>
<div class="wrapper">
<div class="header">
<h1>Electro Geers Bvba</h1>
</div>
<div id="navMenu">
<?php
foreach ($buttons as $button) {
echo '<ul>';
echo '<li><a href="' . h($button['Button']['naam']) . '.html">' . h($button['Button']['naam']) . '</a>';
if (!empty($button['Category'])) {
echo'<ul>';
foreach ($button['Category'] as $category) {
echo '<li><a href="' . $category['naam'] . '.html">' . $category['naam'] . '</a></li>';
}
echo'</ul>';
}
echo '</li>';
echo '</ul>';
}
?>
<br class="clearFloat" />
</div>
<div class="contents">
<h3>Sectionale poorten en Hekwerken</h3>
<?php echo $content_for_layout; ?>
</div>
<div class="footer">
Copyright © 2012 - 2017
</div>
</div>
</body>
I know that cakephp normaly probaly not should be used like this way but i want to know if it is possible? How can i load the button name into default.ctp?
I am currently getting this error:
Notice (8): Undefined variable: buttons [APP\View\Layouts\default.ctp, line 20]
Warning (2): Invalid argument supplied for foreach() [APP\View\Layouts\default.ctp, line 20]