Forum Moderators: open
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.
is there anyway you can elaborate on your suggestion?
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.
-troy
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.
of course, what do i know?
troy.
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!
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.
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
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
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