SitePoint Sponsor |
|
User Tag List
Results 1 to 12 of 12
Thread: How can I load an external file?
-
Feb 3, 2009, 08:01 #1
- Join Date
- Feb 2009
- Location
- Close to Chicago, Illinois
- Posts
- 517
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
How can I load an external file?
Hi,
I’m currently working on a web site where my client wants to be able to update the schedule page and what I’m thinking is to create an external file and then load it to my schedule page, this way it would be easier for him to make updates. I have done this before in flash using actionscript 3.0 but I just don’t know how to do this in an HTML based page.
What would be the easiest way to load an external file into a div or what would you guys recommend?
Thanks,
Fs_tigre
-
Feb 3, 2009, 09:21 #2
- Join Date
- Dec 2003
- Location
- http://kooshin.com
- Posts
- 505
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
perhaps you should use IIS or php includes
-
Feb 3, 2009, 09:36 #3
- Join Date
- Nov 2004
- Location
- Ankh-Morpork
- Posts
- 12,158
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
With HTML you have two options: the deprecated iframe element or the object element (which is poorly supported by IE).
It would be far better if you could use server-side includes as kooshin.com said.Birnam wood is come to Dunsinane
-
Feb 3, 2009, 10:59 #4
- Join Date
- Feb 2009
- Location
- Close to Chicago, Illinois
- Posts
- 517
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Would it be hard to do this using PHP?
-
Feb 3, 2009, 11:15 #5
- Join Date
- Apr 2006
- Location
- Maryland
- Posts
- 1,838
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
PHP Code:<?php include 'file.php'; ?>
-
Feb 3, 2009, 13:01 #6
- Join Date
- Feb 2009
- Location
- Close to Chicago, Illinois
- Posts
- 517
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
So, the only thing I need to do is add this code where I want the file to be loaded? Does the file needs to be a php file?
thanks
-
Feb 3, 2009, 13:06 #7
- Join Date
- Apr 2006
- Location
- Maryland
- Posts
- 1,838
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It depends on how your server is setup, in reality you can have any file extension be it .php, .html, .ext to be processed as a PHP script. The .php extension is the safest and most consistent bet, however if the rest of all your files are .html ( if it was configured like this in the Apache config ) then it's best to be consistent. If you see '<?php' output with a .htm or .html extension that means it hasn't been setup, so either use .php or modify the configuration files.
-
Feb 4, 2009, 04:46 #8
Can we have a look at the lay out of the schedule page and the data that needs to be dynamic? I'm guessing that just including a file isn't going to help too much unless your client knows HTML.
-
Feb 5, 2009, 08:10 #9
- Join Date
- Dec 2008
- Location
- Brussels
- Posts
- 377
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
But, there's a third solution for people who only have client side things:
Let the other pages get loaded with some javascript (AJAX).
Code and example is right here:
http://www.dynamicdrive.com/dynamici...jaxcontent.htm
But keep in mind, the seo disadvantages are even st00pid as with frames/iframes.
-
Feb 5, 2009, 09:48 #10
- Join Date
- Apr 2006
- Location
- Maryland
- Posts
- 1,838
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Well, looking at the situation - the OP basically wants to seperate a page his client is updating so they don't interfere with his edits.
AutisticCuckoo pointed out two HTML solutions - the frame which has the disadvantage of not being indexed by crawlers, and the object element which isn't practical because of the disadvantages of IE.
The best solution which I agree with would be a server-side include, as this would be very reliable.
Had the original poster mentioned that he wanted to pull in dynamic data, or bits and portions of something that is grabbed say, from a database such as maybe a month from a calendar to be displayed, something that is not meant to be static and something which comes in pieces, it would have been best to advise an XHR based solution so that the client wouldn't have the additional page refresh. In this situation, since the data is all static and is not residing in a database: in other words easily accessible it is best to not use an ajax based solution because it relies on a seperate behavior layer - Javascript and it wouldn't be indexed by crawlers either.
-
Feb 5, 2009, 12:38 #11
- Join Date
- Nov 2004
- Location
- Ankh-Morpork
- Posts
- 12,158
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Birnam wood is come to Dunsinane
-
Feb 6, 2009, 09:10 #12
- Join Date
- Feb 2009
- Location
- Close to Chicago, Illinois
- Posts
- 517
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thank you all for the good comments!
Bookmarks