/    Sign up×
Community /Pin to ProfileBookmark

single css menu on multiple pages

i have just introduced myself to php, i am currently developing a website using frames, i have a css menu that has to appear on multiple pages,i have read there is a way of using php to connect the pages but it does not work, i really need help on this one.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@ScottyBoyApr 19.2012 — Usually the way you'd accomplish this would be to put your menu in a separate file and function, and include that file where you need it. For example:

Menu.php
[code=php]
<?php
function menu()
{
echo '
<ul>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
</ul>';
}
[/code]


index.php
[code=php]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Some Page</title>
</head>
<body>';

<?php
require_once('Menu.php');
menu();
?>

<div id="body_content">
<p>something else goes here</p>
</div>
</body>
</html>
[/code]


This is an effective way to split up your website into multiple pieces, which is very useful when you want to add a button to your menu for instance. Then you only have to change it in one place, and it's updated on every page of your website.
×

Success!

Help @Palo_Moshoeshoe 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.11,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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