soycharliente Posted March 16, 2008 Share Posted March 16, 2008 This thread has two "questions" to it. I'm going to lay out the situation and then pose the questions. -= Relevant code =- index.php: <body id="home"> <?php include($_SERVER['DOCUMENT_ROOT']."/lib/header.php"); ?> <div id="main"> <div id="nav"> <?php include($_SERVER['DOCUMENT_ROOT']."/lib/main-nav.php"); ?> </div> <!-- [END nav] --> <div id="content"></div> <!-- [END content] --> <?php include($_SERVER['DOCUMENT_ROOT']."/lib/footer.php"); ?> </div> <!-- [END main] --> </body> lib/main-nav.php: <?php echo <<<DELIMETER <a href="#">Link</a> <a href="#">Link</a> <a href="#">Link</a> DELIMETER; ?> lib/footer.php: <?php echo <<<DELIMETER <div id="footer"> Witty sentence about something will go here. <br /> <a href="#">Link</a> <a href="#">Link</a> <a href="#">Link</a> </div> <!-- [END footer] --> DELIMETER; ?> 1. The navigation in lib/main-nav.php is the same as the navigation in lib/footer.php as you can see. What's the best way to simply include lib/main-nav.php inside lib/footer.php so I can just reuse that code. That way I don't have to update the navigation in multiple places and by updating in one place it will automatically change in any other place I have it. Is this the best way? lib/footer.php: <?php echo <<<DELIMETER <div id="footer"> Witty sentence about something will go here. <br /> DELIMETER; include($_SERVER['DOCUMENT_ROOT']."/lib/main-nav.php"); echo <<<DELIMETER </div> <!-- [END footer] --> DELIMETER; ?> 2. Is there a better way to do this than with "nested includes" because it just seems sloppy and unorganized. Quote Link to comment Share on other sites More sharing options...
JD* Posted March 16, 2008 Share Posted March 16, 2008 depending on how you are formatting it, why not just include the same navigation twice, but wrap it in a different div tag and use css to style it differently? Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 16, 2008 Share Posted March 16, 2008 try <?php require_once("the_page.php"); ?> Quote Link to comment Share on other sites More sharing options...
soycharliente Posted March 17, 2008 Author Share Posted March 17, 2008 <?php require_once("the_page.php"); ?> I don't understand how to apply this. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.