Jump to content
xisto Community
Tramposch

Html Page Aggregator How to bring multiple pages into one page

Recommended Posts

I was wondering if somebody out there had already created an HTML page aggregator. What I want to do is that i have like 50 HTML pages in one directory, just containing a little bit of styling and a little bit of text, no php, js, or anything like that in there, but I want to make an Index.html page that brings each and every one of those pages, and shows ALL its contents in ONE page.Any ideas?

Share this post


Link to post
Share on other sites

how about using frame, or if you prefer php then you could use file_get_contents and then write an output using echo. if the files has similar names like file1.html..file50.html, then it would be easier.

Share this post


Link to post
Share on other sites

you could just read the files as string using file_get_contents command in php, and then give an output using a echo. you could read the tutorial here :

 

http://de2.php.net/file_get_contents

 

an example :

<?php$contents = file_get_contents('file1.html');echo $contents;?>
save as a php file and put in the same directory and try run it.

 

you could insert for command to loop, esp if your files have similarity in name like file1.html, file2.html. ...

 

Could you try this first and tell me whether it works or not. I did try this script once and it worked but i'm not really sure whether this will work or you or not ;)

Edited by akashi (see edit history)

Share this post


Link to post
Share on other sites

Hi!

An alternative approach that simply involves adding in HTML comments is to use server-side includes. Different web server vendors may implement it differently, but with Apache's mod_include module, you simply have to insert something like this:

<!--#include virtual="otherfile.html" -->
in your main file. It will 'merge' the files, making them appear as a single file to the end user. You can also use this approach to develop standardized templates for displaying the header, footer, and navigation menu on the page so you do not have to change it on every page of your website if you do decide to change them - they could all reside in just one file with the web server putting them together whenever a user requests for the web page.

I haven't looked into server-side includes in Microsoft Internet Information Service (IIS) yet so I can't tell you how to do it in IIS but you can install Apache on Windows too as Apache works on pretty much every major platform (Windows, Linux, MacOS, BSD).

Alternatively, you can use PHP. The advantage of using PHP is that you aren't tied to a particular vendor, such as IIS or Apache, since you can install PHP as a module to work with either IIS or PHP. However, you would probably have to deal with security issues if your PHP scripts get complicated. Less software is usually better on servers as you have fewer security issues to deal with.

Regards

Share this post


Link to post
Share on other sites

Hi!I'm guessing the 50 HTML pages might be the result of a batch script that retrieves data from multiple sources, such as different news websites. Either that, or it could be a script that generates files instead of database records to keep things simple (no DBA or email admin intervention required).I would like to mention that the above approaches (other than the IFRAME) suggestion might cause a problem since the internal and external CSS styles applied to the earlier pages would affect the pages following. In-line CSS, however, would not cause this issue. You would also have to ensure that the pages do not have any broken markup as that could affect the rendering of other pages as well.Regards,Nitin Reddy

Share this post


Link to post
Share on other sites

Well, you could just use includes to add the files to make it simpler and so php would be the easiest to go and that way you have an easier time formattign everythign with CSS. Or you could do it in flahs but I think you want to have it indext though.

Share this post


Link to post
Share on other sites

If it is a server running a unix based OS you could use a cron job that calls a command like:

cat * > index.html

That way you don't have to deal with php or js, or really anything. It will just automatically generate an index.html page at whatever interval you specify, that contains the content of all the files in the current working directory.

Share this post


Link to post
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...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.