Jump to content

Calling Footer from Single File to Several Files


amitamberker

Recommended Posts

Okie Everyone... Let me ask you this... Can we STOP discussing about PHP and try to Accomplish This Issue from JS? Because PHP is making my Brain fried..... :(

I wonder if the OP could add a JavaScript that uses JS techniques to write the common footer at the end of his document. Maybe that would make him happy.
Yes. I would be VERY HAPPY if something like this is possible. Edited by creative1977
Link to comment
Share on other sites

initially you don't need to rename all the files to .php but you can rename the calling file .phpinclude() is php language construct so it will work only in php context. include() itself can any file, even .html. eg if your calling file is index.php you can add include "dir/footer.html"; or any other file into it. for this purpose js is not suitable for the reason jsg already told here http://w3schools.invisionzone.com/index.php?showtopic=44225&view=findpost&p=246236 another option could be using iframe. but it will need as many http request as many you include them. php is the prefer way

  • Like 1
Link to comment
Share on other sites

What's wrong with renaming files? You only have to do that once. There are tools to do a batch rename, other tools to find and replace text across multiple files. Rename your files so you can use PHP.
Hi justsomeguy,Because all the .html files has be designed as per HTML Standards. If I change it to .php then perhaps everthing (the Concept of Layout) might get messed-up. The Layout might look strange. I feel comfortable with .html file.I think maybe I should "Give Up" and just keep doing what I have been doing.
Link to comment
Share on other sites

nothing will change. You can still change the name to .php and everything would remain the same. I think it's just obvious that are you not very aware of how PHP works, or else you would undertand that you could do something like this, and nothing would change relative to the output. somepage.php

<html>  <head>	<title>Im a page</title>  </head>  <body>	<p>Im some content.  It would be no difference if I was an .html page, or a .php page at this time.</p>     <p>The PHP interpreter would never even be called because there are no <?php tags in this code, so instead the markup will be directly sent to the browser.</p>  </body></html>

Edited by thescientist
  • Like 1
Link to comment
Share on other sites

initially you don't need to rename all the files to .php but you can rename the calling file .phpinclude() is php language construct so it will work only in php context. include() itself can any file, even .html. eg if your calling file is index.php you can add include "dir/footer.html"; or any other file into it. for this purpose js is not suitable for the reason jsg already told here http://w3schools.inv...ndpost&p=246236 another option could be using iframe. but it will need as many http request as many you include them. php is the prefer way
Hi birbal, I have already renamed the calling file as .php My footer.php is:
<div>blah... blah... blah... © 2003 - 2012. | All rights reserved</div>
Could you please explain this again? include() is php language construct so it will work only in php context. include() itself can any file, even .html. eg if your calling file is index.php you can add include "dir/footer.html"; or any other file into it. My SeveralPages.html is:
<div class="footer"><?php include 'footer.php'; ?></div>
1. Somehow "blah... blah... blah... © 2003 - 2012. | All rights reserved" is not visible upon publishing on IE Web Browser.2. Upon publishing on IE Web Browser, the whole Container (Design) is moving towards Left Side. Edited by creative1977
Link to comment
Share on other sites

nothing will change. You can still change the name to .php and everything would remain the same. I think it's just obvious that are you not very aware of how PHP works, or else you would undertand that you could do something like this, and nothing would change relative to the output. somepage.php
<html>  <head>	<title>Im a page</title>  </head>  <body>	<p>Im some content.  It would be no difference if I was an .html page, or a .php page at this time.</p>     <p>The PHP interpreter would never even be called because there are no <?php tags in this code, so instead the markup will be directly sent to the browser.</p>  </body></html>

Hi thescientist,Thanks for some Useful and Helpful inputs BUT HOWEVER, I prefer to stay with .html instead of ReNaming all my .html to .php....... I just feel Easy and Comfortable with .html while working Offline so that I could see / check / review instantaneously the progress of Updates and Development of HTML Webpages on IE Web Browser. What happens in .php is, I have to Upload eachtime into the Server from CoreFTP or FileZilla to review the Status on IE Web Browser.
Link to comment
Share on other sites

What's wrong with renaming files?
Hi justsomeguy, If I rename my .html as .php, then I cannot work. Each time I have to keep Uploading into Client's Server from FileZilla OR CoreFTP to check the status. Edited by creative1977
Link to comment
Share on other sites

HTML files have NO include capability.
Hi So Called,What does it means? Did I do something wrong in my SeveralPages.html file?
Link to comment
Share on other sites

Hi birbal, I have already renamed the calling file as .php My footer.php is: Could you please explain this again? include() is php language construct so it will work only in php context. include() itself can any file, even .html. eg if your calling file is index.php you can add include "dir/footer.html"; or any other file into it. My SeveralPages.html is: 1. Somehow "blah... blah... blah... © 2003 - 2012. | All rights reserved" is not visible upon publishing on IE Web Browser.2. Upon publishing on IE Web Browser, the whole Container (Design) is moving towards Left Side.
Sounds like you aren't getting it. The file to be included DOES NOT have to be a php file. Any file that has php code in it, DOES need to be a PHP page. I don't know why you named footer to be .php, or why you haven't read the tutorials, it's makes this all pretty clear.
Hi thescientist, Thanks for some Useful and Helpful inputs BUT HOWEVER, I prefer to stay with .html instead of ReNaming all my .html to .php....... I just feel Easy and Comfortable with .html while working Offline so that I could see / check / review instantaneously the progress of Updates and Development of HTML Webpages on IE Web Browser. What happens in .php is, I have to Upload eachtime into the Server from CoreFTP or FileZilla to review the Status on IE Web Browser.
Well, most (smart) developers have an AMP (Apache/MySQL/PHP) stack installed on their machine so they don't have to upload their work to a remote server everytime, so they can test locally. Edited by thescientist
Link to comment
Share on other sites

Hi So Called, What does it means? Did I do something wrong in my SeveralPages.html file?
yes
<div class="footer"><?php include 'footer.php'; ?></div>

There's PHP code in a .html file.

Edited by thescientist
Link to comment
Share on other sites

Hi thescientist,I don't know what to say OR how to reply to your response. I am just confused. I think maybe I should just Give-Up and move-on?

Link to comment
Share on other sites

yes
<div class="footer"><?php include 'footer.php'; ?></div>

There's PHP code in a .html file.

Hi thescientist,But justsomeguy said the Code looks correct and you are saying it's wrong? WOW!!!...
Link to comment
Share on other sites

Guest So Called

You cannot have PHP code in an HTML file because HTML files are not processed by the PHP processor. The only way you could have that work would be to modify your .htaccess file to have the PHP processor process HTML files too, which has already been mentioned in this topic.

Link to comment
Share on other sites

Hi thescientist, But justsomeguy said the Code looks correct and you are saying it's wrong? WOW!!!...
I think he was implying that if you made the changes he suggested in the post before he said that (which has been the same thing everyone else has been trying to tell you), then yes, it would be correct. But since you still have all the extensions wrong, even with the right code, your implementation remains wrong. Please, for the sake of everyone in this thread, read the PHP tutorials, or if you don't want to learn/understand it, then just follow up on the JS implementation that was suggested, knowing all the possible disadvantages already presented.
Link to comment
Share on other sites

First off, I'll admit that I haven't read the entire thread so if this has been mentioned, forgive me. For the sake of simplicity, if you are potentially going to have <?php?> code on a page some day, wouldn't it be easier to just make ALL of your pages have a .php extension? I mean, what would it hurt? I'd hate to have a site with 10 .php pages and 30 .html pages then make changes that require 5 pages to become .php pages and have to go back and change links, etc... I know it kinda short cuts the learning experience, but my experience in the real world (not with coding) is that short cuts are the norm.... Just a suggestion. Take it for what it worth.

Link to comment
Share on other sites

If you're not willing to change your files to PHP files then there's nothing else to do here, just move on. You can only do what you're trying to do if you rename your files. There are plenty of ways to test locally. PHP 5.4 even has a built-in test server. But if you're not willing to go through that, then just move on and keep using static HTML files.

Link to comment
Share on other sites

Guest So Called

Or OP can have Apache process all his HTML files with the PHP processor: http://www.velvetblues.com/web-development-blog/how-to-parse-html-files-as-php/http://php.about.com/od/advancedphp/p/html_php.htmhttp://www.google.com/search?q=htaccess+php+process+html+files It amounts to adding one or more lines to your .htaccess code to tell Apache to send them to the PHP processor. However I cannot imagine a professional doing something that clunky. But I'm sure it would work.

Link to comment
Share on other sites

Or OP can have Apache process all his HTML files with the PHP processor: http://www.velvetblu...l-files-as-php/http://php.about.com.../p/html_php.htmhttp://www.google.co...cess+html+files It amounts to adding one or more lines to your .htaccess code to tell Apache to send them to the PHP processor. However I cannot imagine a professional doing something that clunky. But I'm sure it would work.
The problem I see with doing that is when you move it to a live site, if you don't have access to change the .htaccess. I would rather make all of the pages .php to start with....
Link to comment
Share on other sites

If you're not willing to change your files to PHP files then there's nothing else to do here, just move on. You can only do what you're trying to do if you rename your files. There are plenty of ways to test locally. PHP 5.4 even has a built-in test server. But if you're not willing to go through that, then just move on and keep using static HTML files.
Hi justsomeguy, This is getting harder and harder day-by-day. I think maybe I have achieved (resolved) this by myself with the help of <iframe>......</iframe> tags. Please find the attached "Calling Footer from Single File to Several Files.zip" file for your reference. Please let me know if I could go-ahead with this or not. Hello Everyone, Thanks a lot for all your support and help BUT I am feeling this hard. Unfortunately dsonesuk is not around. Maybe he would have told me what needs to be done and I could have just followed him. But anyways........... No worries. Please find the attached Zip file for your reference.

Calling Footer from Single File to Several Files.zip

Edited by creative1977
Link to comment
Share on other sites

Guest So Called
The problem I see with doing that is when you move it to a live site, if you don't have access to change the .htaccess.
Not sure what you mean by a live site. My production site runs on a shared hosting service and I have full access to make my .htaccess file anything I want. What kind of place would not have that?
Link to comment
Share on other sites

Not sure what you mean by a live site. My production site runs on a shared hosting service and I have full access to make my .htaccess file anything I want. What kind of place would not have that?
The host I used in the past was so restrictive, I'm not sure if I could make changes like that or not. It might have been possible, I never asked. It just seems easier to me to give all of my pages a .php extension and be done with it. Currently, I don't have an active site/host, I just practice on my own computer with EasyPhp.
Link to comment
Share on other sites

Guest So Called

Maybe you used one of those free hosting services. Paid shared hosting services cost about $5-$8 per month, we worth the price IMO. Even for hobbyists or students it's $80 a year well spent. And you don't have to deal with restrictions like not being able to add/modify .htaccess or php.ini files, and don't have to bother with setting up or maintaining software like Linux, Apache, PHP, MySQL.

Link to comment
Share on other sites

Yea, it was a free host. I figured it would be better to see if I wanted to actually work on a web site/development/scripting before I spent the money for a good host. Currently, I'm sticking with practice at home.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...