rassul Posted April 5, 2013 Share Posted April 5, 2013 Hello, I have several pages that have exact the same footing text. How would I have the content in one place and somehow refer to it in my footer div of each page? Thank you in advance. Link to comment Share on other sites More sharing options...
Ingolme Posted April 5, 2013 Share Posted April 5, 2013 HTML can't do it, but if you learn some server-side scripting you can get it done. PHP is the most popular one, you can learn it here: http://w3schools.com/php/ Normally, rather than putting the footer into every page, in PHP you'll have one page template and put the content into it based on the URL. PHP uses the include() directive for that. 1 Link to comment Share on other sites More sharing options...
rassul Posted April 5, 2013 Author Share Posted April 5, 2013 Thanks for the response. I do know some PHP. But can it be done via Javascript? Link to comment Share on other sites More sharing options...
Ingolme Posted April 5, 2013 Share Posted April 5, 2013 The problem with attempting a workaround with Javascript is that your site isn't going to work for people who navigate with Javascript disabled. It's also invisible to search engines and it slows down the loading of your page. If your server supports PHP, just put this in every page: <?php include('footer.php'); ?> If you want to test first on your computer, you can download WAMP to test your PHP pages. Link to comment Share on other sites More sharing options...
rassul Posted April 5, 2013 Author Share Posted April 5, 2013 HTML can't do it, but if you learn some server-side scripting you can get it done. PHP is the most popular one, you can learn it here: http://w3schools.com/php/ Normally, rather than putting the footer into every page, in PHP you'll have one page template and put the content into it based on the URL. PHP uses the include() directive for that. How would you do it using PHP? Link to comment Share on other sites More sharing options...
Ingolme Posted April 5, 2013 Share Posted April 5, 2013 I just showed you in my previous post. Put this in each of your pages: <?php include('footer.php'); ?> Assuming the contents if your footer is in a file called "footer.php" Link to comment Share on other sites More sharing options...
rassul Posted April 5, 2013 Author Share Posted April 5, 2013 The problem with attempting a workaround with Javascript is that your site isn't going to work for people who navigate with Javascript disabled. It's also invisible to search engines and it slows down the loading of your page. If your server supports PHP, just put this in every page:<?php include('footer.php'); ?> If you want to test first on your computer, you can download WAMP to test your PHP pages. I am using wamp. Here is my footer.php:<?php echo "<p>This is footer</p>";?> and place <?php include('footer.php'); ?> where the footer should be, but does not work. Link to comment Share on other sites More sharing options...
rassul Posted April 5, 2013 Author Share Posted April 5, 2013 I am using wamp. Here is my footer.php:<?phpecho "<p>This is footer</p>";?> and place <?php include('footer.php'); ?> where the footer should be, but does not work. I am inserting <?php include('footer.php'); ?> in my index.html file. Link to comment Share on other sites More sharing options...
Ingolme Posted April 5, 2013 Share Posted April 5, 2013 The file has to have a .php extension. Rename it to index.php Link to comment Share on other sites More sharing options...
rassul Posted April 6, 2013 Author Share Posted April 6, 2013 I am inserting <?php include('footer.php'); ?> in my index.html file. Thanks for everybody's suggestions. I changed all of my html files' extensions from .html to .php and now it works. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now