Content in DIV

Permabanned
Joined
18 Oct 2002
Posts
12,841
Location
Lost!
Stupid question but its been a long time since i did any of this...

I have a DIV container, inside this is the logo followed by another DIV menu and then below that the DIV for content.

Obviously the logo and the menu stay the same on every page, but the content in the content div changes....

When creating a page for menu item 1, do i replicate the enitre container, logo and menu code on every page for different content, or do i "call" content into the div somehow???
 
You could use PHP includes, so you have one main page with the standard layout and then you include the content section from separate files.
 
You can do it multiple ways.

You can duplicate your navbar on each page. A pretty standard way of doing things and the best for SEO. But manageability goes out the window for a larger site considering that 1 menu change has to be changed on X # of pages.

Use an iFrame for the content div. Not great for SEO.

Use some coding to include the info you desire.

Ultimately.. best to just duplicate the nav bar. Thats what I did on my site.
 
I'm aware of php includes but as this is probably a temp site being replaced by full e-commerce soon i shall just replicate the nav ba on each page.

Thanks chaps :)
 
Don't replicate the menu on every page!!

For the love of all that's holy, use an include. Even if the menu is only used on 2 pages, use an include.

It takes no extra development time to code, but it may save you days of work later on down the line if you need to amend the menu for any reason.
 
Don't replicate the menu on every page!!

For the love of all that's holy, use an include. Even if the menu is only used on 2 pages, use an include.

It takes no extra development time to code, but it may save you days of work later on down the line if you need to amend the menu for any reason.

Yeah, this. You're virtually guaranteed to have access to some sort of server side include functionality, almost certainly PHP or Server Side Includes.

Write your navigation code first and save it in a separate file:

nav.html
Code:
<ul id="navigation">
    <li><a href="/">Home</a></li>
    <li><a href="/pandas/">Pandas</a></li>
    <li><a href="/koalas/">Koalas</a></li>
</ul>

Then include it on each page on which you want it to appear, either via PHP:

Code:
<h2>Pandas</h2>

<?php include 'nav.html'; ?>

<p>Pandas are excellent.</p>

...or via SSI:

Code:
<h2>Pandas</h2>

<!--#include file="nav.html" -->

<p>Pandas are excellent.</p>

If you're using PHP, pages that include the navigation will need a .php file extension; if you're using SSI, they'll need a .shtml file extension.
 
Folllowing on from this i have implemented the php includes, however my CSS file no longer "controls" the appearance of the menu....how do i make this work still?
 
We need a bit more info.

Have you "included" the page header?
Is the CSS file in the right location and being found by the page?
Is it only the menu that is affected?
 
Where i have the menu in the index page i have put this

Code:
<div class="border" id="menu"><?php include 'menu.htm'; ?></div>

The contents of this file are...

Code:
<a href="winching.php" target="_self">WINCHING</a> | <a href="service.php" target="_self">SERVICE KITS</a> | ROPES | BRAKES &amp; CLUTCHES | ELECTRICAL | SUSPENSION | AXLES
 
It's most likely a problem with the CSS somewhere as having an include file is the equivalent of copying and pasting the included file into the parent document where you specified. Any CSS on the parent page will be applied.

Is it just the menu which is not being styled or the whole page?
 
Back
Top Bottom