Kyle
Kyle

Reputation: 366

cakePHP why does my view not display properly

I was given a project to update a cakePHP website a few days ago and I'm having some issues. I've been reading through the cakePHP cookbook, but I don't understand why a page that I am creating from scratch does not display in a browser properly.

Here's what I have:

A default model 'contact.php'. And A view inside the directory /app/views/pages/ called contact.ctp with the code:

<h1 class="page-title left">Photo Tour</h1>
 <div id='map'>  
<img src="/img/map.png" alt"Map to Our Location"/>  
<p> Hello</p>
 </div> 

 <p>Hello</p>

When I go to the home page and click on the 'contact us' page link, the title bar changes to 'Contact Us' as it should, but nothing displays on the page itself.

Also, 'map' is defined as a div in the master.css file.

Any ideas why this is?

Upvotes: 1

Views: 601

Answers (1)

huzzah
huzzah

Reputation: 1805

If your navbar and logo are displaying, then your layout page is working correctly, but your contact.ctp data may not be. Be sure that your layout.ctp file contains the following:

<?php echo $content_for_layout; ?>

In your case, it looks like your code should look something like this:

<html>
  <body>
   <header>
     <a href="http://www.site.com><img src="header_logo.jpg"></a>
    <div id="navbar">
       <ul>
         <li>MenuItem</li>
         <li>MenuItem</li>
         <li>MenuItem</li>
         <li>MenuItem</li>
       </ul>
    </div>
   </header>
   <section>
   <?php echo $content_for_layout; ?>
   </section>
  <footer>Here is the footer information</footer>
  </body>
 </html>

Upvotes: 3

Related Questions