/    Sign up×
Community /Pin to ProfileBookmark

css menu as an include file

Hi guys. The site im working on will include lots of pages. In the side nav I have a menu in a div looking like this below:

<div id=”menu”>
<ul>
<li><a href=”/” title=”Search”>Search</a></li>
<li><a href=”/” title=”Branch Directory”>Branch Directory</a></li>
<li><a href=”/” title=”House Prices”>House Prices</a></li>
<li><a href=”/” title=”Guide to Buying”>Guide to Buying</a></li>
<li><a href=”/” title=”Viewing Tips”>Viewing Tips</a></li>
</ul>
</div>

There maybe times when another link needs to be added. Therefore instead of goin through everypage and changing manually, is there a way i can include this file from an external include file?

The CSS for this is not embedding within the page

Thanks

to post a comment
CSS

5 Comments(s)

Copy linkTweet thisAlerts:
@ryanbutlerJan 31.2007 — Sure, take this:

[CODE]<ul>
<li><a href="/" title="Search">Search</a></li>
<li><a href="/" title="Branch Directory">Branch Directory</a></li>
<li><a href="/" title="House Prices">House Prices</a></li>
<li><a href="/" title="Guide to Buying">Guide to Buying</a></li>
<li><a href="/" title="Viewing Tips">Viewing Tips</a></li>
</ul>[/CODE]


Name it navigation.shtml or a server side include, such as navigation.php, navigation.asp, etc.

Inside each page, remove the code highlighted above and place a call to it:

[CODE]<div id="menu">
<?php include('navigation.php');?>
</div>[/CODE]


Or call a SHTML menu if you use navigation.shtml:

[CODE]<div id="menu">
<!--#include file="navigation.shtml" -->
</div>[/CODE]


You manage all your links inside the include now and they updated automatically.
Copy linkTweet thisAlerts:
@ranjistinosauthorJan 31.2007 — Thanks Ryan,

I chose the shtml option. The problem is in Dreamweaver design view the include shows, but when I view it in a browser the navigation is not appearing. Does this suggest theres something wrong with my css?

Thanks
Copy linkTweet thisAlerts:
@ryanbutlerJan 31.2007 — It indicates something is wrong with the include file. Are you sure the include file contains nothing else except your unordered list? Oh, I did forget one thing, I believe you'll need to rename the file which includes the menu to index.shtml, if the page is named index, that's probably the problem.
Copy linkTweet thisAlerts:
@ranjistinosauthorFeb 01.2007 — Does it need to be running on a server, ie IIS 6?
Copy linkTweet thisAlerts:
@felgallFeb 01.2007 — It needs to be running on a web server that has SSI enabled.
×

Success!

Help @ranjistinos spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...