Forum Moderators: open

Message Too Old, No Replies

externally loading html

having problems finding pertainent information

         

xxenn

6:34 am on May 23, 2002 (gmt 0)



for the past few months, i have been toiling through hundreds of pages looking for information on externally loading html. of course, i hear the easiest way to accomplish this task is to use the external load code accompanied with php tags; however, my particular host refuses to issue a simple update to handle php.

basically, what i wanted to create was a navigational menu that can be externally loaded into the main interface. since the topics are changing daily, the external html would be essential as to avoid the rewriting of 100s of pages upon each update. i know this is a common thing, and i remember reading something about a small script to load an external .js file.

unfortunately, the only information that i have come across seems to include massive scripting for such a small function. perhaps someone can point me in the right direction or offer some solace to this otherwise daunting task.

Nick_W

6:45 am on May 23, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm afraid your best bet is to get another host. Won't/doesn't have php? Sheesh!

Nick

xxenn

6:59 am on May 23, 2002 (gmt 0)



i was beginning to think the same thing as this entire situation has frustrated me into cursing at my monitor, actually leaving my house in an attempt to find a life, and many other bad things. such a sickening tragedy. not as terrible as edipus rex or anything, but a tragedy nonetheless.

Marcia

7:15 am on May 23, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why not use Server Side Includes instead of JS? A simple, quick change in one text file changes the navigation on all the pages at once if the include command is in there. It's all done server side and you can do an entry in .htaccess so it'll work with .html and .htm instead of just .shtml

xxenn

7:25 am on May 23, 2002 (gmt 0)



evidently, i am extremely new to all these new technologies. ironically, i started designing about 10 years ago. unfortunately, i have been out of the game for a long while and am back on the ropes. sad, really.

is there anyway you can elaborate on your suggestion?

Marcia

8:59 am on May 23, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Using scripts is the best solution, but using SSI is the simplest way.

To "include" information on a page, you put the exact section of code you want inserted onto your pages into a regular ascii text file, same as if it were going directly onto your pages. No more, no less.

If you put the text file into the site root directory, you place this command on the pages exactly where you want that piece of code to appear:

<!--#include virtual="/filename.txt" -->

If the text file will be placed into a directory on the site you insert the following where you want the code to appear:

<!--#include virtual="/directoryname/filename.txt" -->

It isn't a mistake, there's an extra space that goes before the -->

It's processed by the server before the browser ever loads the page and it's not possible for either the surfer or bots to distinguish the difference, it's included on the page before it ever loads.

You can put that include line on 1,000 pages and the same code and text will appear on all of them wherever you put it, with only making an entry into that one text file.

The pages are generally .shtml but you can put a couple of lines into .htaccess which is simply an ascii text file that resides in the root directory of the site. If uploaded by FTP make sure it doesn't upload as binary, it has to be ascii text. I just create them through the control panel, generally.

It will also work for .htm or .html pages if you put this in .htaccess

AddType text/html .html
AddHandler server-parsed .html
AddHandler server-parsed .htm

Then those file types will be parsed as though they were .shtml pages

You don't have to understand how it works, it just does. This is only for Apache servers, if it's IIS or NT I don't have a clue.

If there are any problems, just ask here, showing the code you used. And double check that the host supports it. If your host doesn't support PHP and also doesn't support Server Side Includes (SSI) send them packing and move to another host.

Hope this helps. Stick around, everything you need to know is right here.

xxenn

4:57 am on May 29, 2002 (gmt 0)



i attempted the ssi additions that you mentioned in a test; however, it seems that my server is the runt of the litter. in fact, the runt of the litter used to beat up my server on the playground. that seems to be the only reason why it still has yet to mature into a full-featured, respectable, responsible, and reliable server.
i suppose my next question might be: any thoughts on any particular hosts? i had a couple in mind, but i think with recent economic factors, they all went under (remember, i actually started in the dark ages of the internet -- that is, when technophiles sat in darkened rooms, drinking far too much caffeine, and drooling over the latest ascii-based games on their local bbs ... who could forget "legend of the red dragon?").
i do wish to thank you for the information offered. thank you so deeply.

-troy

Visit Thailand

6:14 am on May 29, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Forgive me for asking this but the suggestion above of using .htaccess to parse all .htm and .html files is very server intensive is it not.

If you have 5-10,000 such pages then parsing them all would slow down the server considerably no ?

keyplyr

9:23 am on May 29, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



> ...using .htaccess to parse all .htm and .html files is very server intensive is it not.

It was with my sever. I chose to pull page menus and other external files with .js instead. Once the file is loaded in the browser's cache, it's instant for all other pages vs the sluggish SSI. Also, just how many other people are running AddHandlers will certainly come into play.

xxenn

10:20 pm on May 29, 2002 (gmt 0)



originally, i had wanted to use .js to simply cache the particular lines of code (ie. the navigational menu) for use on every page; however, i never really used javascript extensively. perhaps, i need to go through and relearn the language basics. after all, i don't think what i am attempting to accomplish is such a hard task. in fact, if i recall, it is simply a matter of writing out a .js file and created a script to call up the aforementioned file.

of course, what do i know?

troy.

Marcia

10:49 pm on May 29, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



keyplyr, how about pages getting spidered and links being followed using JS menus for navigation?

keyplyr

12:30 am on May 30, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



>... how about pages getting spidered and links being followed using JS menus for navigation?

Marcia, the way I deal with that is:

- I use text links to all major categories from the index page (spider food)

- I only use JS menus on secondary pages as a quick nav.

- I have a root level site map with full URLs for all pages (spider food)

- All the pages use KW text links back and forth as appropriate for relevant content (spider food)

xxenn, create a .txt file and name it menu.txt Then at the top put:

<!--

Then start every line of code with: document.writeln('

and end it with: ');

And end your file with: //-->

also, JS reads forward slashes as a termination, so insert a backwards slash preceeding the forward slash, example: <\/a>

Then rename your file to menu.js and upload in binary mode. Use the inline code on the page:

<script language="JavaScript" type="text/javascript" src="http://your_domain.com/path/menu.js"></script>

Put this code in the exact place you want the menu to appear. Viola!

madcat

1:04 am on May 30, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why not use Server Side Includes instead of JS?

-What about PHP though?

Hi Marcia- Are PHP and SSI usually used in conjunction with each other? Or, could I do it all in PHP?

Thanks,
M

brotherhood of LAN

1:13 am on May 30, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can do it all in PHP

xxenn

1:17 am on May 30, 2002 (gmt 0)



keyplyr:

somehow, i knew it would be as simple as that. in fact, somewhere in the dark recesses (and, yes, they are very dark) of my brainpan, i actually knew the rudimentary basis of the function you mentioned. i guess it was just because i never taught myself how to write js-based code.

tonight, i will run a test on your suggestion. of course, i know it will work (because the dark recesses tell me so!). thank you kindly for your words of wisdom.

troy.

madcat

1:24 am on May 30, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can do it all in PHP

Thanks b_o_l, I thought so...Would you recommend this approach and cut out SSI altogether? ::

I've heard many good things about SSI but will drop it if this route is more streamlined.

Best,
M

david752

4:39 pm on May 30, 2002 (gmt 0)

10+ Year Member



I was under the impression that most servers are either:

Unix/Apache, for which PHP is the best combination of ease of programming and universality of availability in the server, or Windows/IIS, for which ASP.

I don't know if Unix/Apache servers generally support ASP (I suspect not), or whether Windows/IIS servers generally support PHP.

It would be nice to have a universally-supported server-side full programming language (full means not just SSI/shtml) like PHP and others, but it's probably not possible in the near future.

For me, server availability is a more important concern than the specific features of the programming language.

Parenthetically, I use PHP for almost every page of my sites in spite of the server loading and slower page loading, because this gives me an enormous amount of flexibility in generating NN4-compatible HTML, parameterizing things like color schemes, using simulated cookies (stored in a site file) that are always available instead of browser-specific Javascript cookies, and many other purposes. For including text, it is much easier to write and read than using "<script>" and separate js files, and this translates into faster Web development.

I wish that the server-side code (other than unsafe things like server file references) could easily be written for execution by the browser, but such is not usually the case.

David

ergophobe

4:53 pm on May 30, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




I don't know if Unix/Apache servers generally support ASP (I suspect not)

You suspect right. There is an Apache module to add ASP support, but I don't think it's considered "production ready". In any case, unless you have a dedicated server, you probably can't find a shared hosting solution that offers it.


or whether Windows/IIS servers generally support PHP.

Again it's available and could be considered production ready, but support is rare, perhaps non-existent on a shared host.

Madcat,

I don't use SSI, but PHP gives you so much more flexibility, I don't see why you would mix them since....

1. If you are using PHP for anything more complex than include()/require(), then you are locked into a server that supports PHP, so why not stick to it?

2. If all you are doing is include()/require() then you can redo an entire site from php to whatever kind of include you are using in a few seconds using grep or a similar tool like BKReplacem.

Tom

madcat

5:52 pm on May 30, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi ergophobe- Nope. I'll be starting from scratch. I'm in the process of switching servers so my dialogue with PHP will begin shortly.

brotherhood of LAN

6:15 pm on May 30, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



When trying to "test" a site i made using FP generated ASP on to a Linux/Apache server, I was told it would not work because it was Windows ASP, which must be integral to IIS. (?)

The solution by the tech was to use Chili ASP, so I assume that some Linux/Apache servers dont have a problem with it, its just that its slightly different ASP (?)

Back to the wide topic, I guess its a question of what you feel most comfortable with...ASP PHP or the like