Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Build a Simple PHP Application Creating the Menu and Footer Including the Header

Evan Ratzlaff
Evan Ratzlaff
776 Points

Foundation 5 and php

Randy,

Ok, i'm following along here with your course on building a simple php application. I'm running into a bump.

So I built my site using foundation 5 framework. I'm using topbar as my navigation across all the pages. All the pages are currently in html except the contact page which is a pretty long line of php.

So i need to get my navigation on the contact page. I have done as you have and i cannot for the life of me get the navigation to show up. Am I doing something wrong?

here is code from index.html head:

<!doctype html> <html class="no-js" lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Halstead Tire | Tire Professionals</title> <link rel="stylesheet" href="css/app.css" /> <script src="bower_components/modernizr/modernizr.js"></script>

  </head>
  <body>

<!-- Site navigation -->

<div class="row">
    <div class="large-12 columns">



        <div class="contain-to-grid-sticky">
                <nav class="top-bar" data-topbar>
                    <ul class="title-area">
                        <li class="name">
                            <h2>Halstead Tire LLC</h2></li>
                        <li class="toggle-topbar menu-icon"><a href="#">Menu</a>


                        </li>           
                    </ul>

                    <section class="top-bar-section">
                        <ul class="right">
                            <li><a href="index.html">Home</a></li>
                            <li><a href="services.html">Services</a></li>
                            <li><a href="tirecare.html">Tire Care</a></li>
                            <li><a href="form-contact/contact.php">Contact Us</a></li>              
                        </ul>
                    </section>  
                </nav>
        </div>      
    </div>
</div>  

  <script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="bower_components/foundation/js/foundation.min.js"></script>
<script src="js/app.js"></script>

I changed the name of the index.html to index.php. I put the above code into a file named header.php which is in a folder called "inc"

Next i added the following code to php include just as you did in the course.

The header nav doesnt show up. What's wrong with my code?

2 Answers

Gergő Bogdán
Gergő Bogdán
6,664 Points

Hi,

Have you used Blade sections ? The idea would be to have a main layout, have for example the navigation and all the common things there, and only insert the content section using the Blade template engine.

What is the code on your Contact page? I assume you are not referencing the index.html and that is why the navigation is not appearing.

Evan Ratzlaff
Evan Ratzlaff
776 Points

To be real honest, my contact page is rather long. I actually purchased a form off of envato because i'm not fluent in php. Do you have an alternate email address you can be reached at? Its way to long to post the code on the forum.

Gergő Bogdán
Gergő Bogdán
6,664 Points

You can add the file to GitHub or Bitbucket and paste link here, or you can find my email address on my website :)