How to set data from database to element?

Hello guys i am new in cakephp and php too. I have changed default layout to me template and created 1 controller with index method, but also i created 2 lements menu( in top ) and footer in bottom how can get data from my database to my elements?


$cakeDescription = __d('venere', 'Venere: Оливки масла маслины');

 <!DOCTYPE html>
<html lang="ru">
        <?php echo $this->Html->charset(); ?>
        <!-- Responsive meta -->
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <!-- IE Compatibility meta -->
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
       	echo $this->Html->meta('icon');

		echo $this->Html->css(['bootstrap.min','','','slider.min','lightbox.min','datepicker.min','timepicki.min','owl.carousel.min','style.default']);
		echo $this->Html->script(['','bootstrap.min','','jquery.slitslider.min','owl.carousel.min','lightbox.min','datepicker.min','datepicker.en.min','timepicki.min','jquery.validate.min','smooth.scroll.min','script']);

		echo $this->fetch('meta');
		echo $this->fetch('css');
		echo $this->fetch('script');
        <!-- Page Title -->
		<?php echo $cakeDescription ?>:
		<?php echo $this->fetch('title'); ?>

        <!-- Modernizr -->
        <script type="text/javascript" src="js/modernizr.custom.79639.min.js"></script>

        <div class="page-holder">
            <!-- Navbar -->
            <header class="header">
            </header><!-- End Navbar -->

<?php echo $this->fetch('content'); ?>

            <!-- Footer -->
            <!-- End Footer -->

            <!-- scroll top btn -->
            <div id="scrollTop" class="btn-unique">
                <i class="fa fa-angle-up"></i>
            </div><!-- end scroll top btn -->


element footer


Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.

                        <div class="col-md-4 contact">
                            <div class="header">
                            <ul class="contact list-unstyled">
                                <li><span class="icon-map text-primary"></span>Basioun, 23 July st, Egypt</li>
                                <li><a href=""><span class="icon-phone text-primary"></span></a></li>
                                <li><span class="icon-mail text-primary"></span>9465 7675 294</li>
                                <li><span class="icon-printer text-primary"></span>333-999-666</li>

                        <div class="col-md-4 newsletter">
                            <div class="header">
                            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit sed do eiusmo.</p>
                            <form action="#" id="subscribe" class="clearfix">
                                <input type="email" name="subscribtion-email" placeholder="Enter Your Email Address" class="pull-left">
                                <button type="submit" class="btn-unique has-border pull-left">Subscribe</button>


                <div class="copyrights">
                    <div class="container">
                        <div class="row">
                            <div class="col-sm-5">
                                <ul class="list-unstyled list-inline">
                                    <li><a href="#">Policy Privacy</a></li>
                                    <li><a href="#">Terms of Use</a></li>
                                    <li><a href="#">Contact</a></li>

                            <div class="col-sm-7">
                                <p>&copy; 2017 Italiano Restaurant. Template By <a href="" target="_blank"></a></p>
                                <!-- Please do not remove the backlink to us unless you have purchased the attribution-free license at It is part of the license conditions. Thanks for understanding :) -->

What you exactly want to achieve? Isn’t your menu and footer permanent? Are they changing based on something? Why do you need to query the database for these?

If you are new to the PHP then You shouldn’t use framework, for now, learn Php to an intermediate level then go for the framework. And for your question, go through edit() function of your controller and edit.ctp view. You can easily figure it out that how a data from a database is been fetched. I would also recommend you to use book.cakephp it has all the solution. Try it and if you still failed to do so, show us what you have tried, then I will help you. But you must try it yourself first.

1 Like