Forum Moderators: open

Message Too Old, No Replies

SSI question

SSI for navigation

         

Artmaker

6:23 pm on Mar 6, 2017 (gmt 0)

5+ Year Member



Hi all,
Well my site, which I have been hand coding since the late 90s, (don't laugh, it works for me.)

Anyway the thing has grown into a monster. Some time ago I learned how to include a bit of SSI just for navigation. It works fantastic and has saved a ton of time just editing one page any time something is added or removed. BUT…
The problem is every single page I use it on has to sit in the main directory.
Well I want to divide my site into two main parts. What I have now is basically a show and tell, portfolio of what I do sort of thing and I want to leave that as is.
But now I want to open an on line store. Just to make my life simple EVERYTHING associated with the store section I'd love to just put in a sub directory called "store."
BUT that breaks how the SSI works. Unless there is a trick I don't know about.

Is there a way to use SSI the way I have on the rest of my site but build everything within this sub directory?

topr8

8:05 pm on Mar 6, 2017 (gmt 0)

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



i think you misunderstand how ssi work.
you should be able to keep the include files anywhere that the webserver has access too, infact it is generally good practice to have them 'above' the root of the website.

Artmaker

8:23 pm on Mar 6, 2017 (gmt 0)

5+ Year Member



They would never work on any given page unless the page using one ends in SHTML AND is located in the main, or public directory. I never could put a page in a sub folder and have that work. Even if I call it up with the full http…. yada yada link.

topr8

8:49 pm on Mar 6, 2017 (gmt 0)

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



how are you including the include in a page

(btw. apache or iis)

topr8

8:56 pm on Mar 6, 2017 (gmt 0)

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



are you doing this:

<!--#include file="included.html" -->


you should probably doing this:

<!--#include virtual="/path/from/root/included.html" -->


'file' only works within the same directory

lucy24

10:05 pm on Mar 6, 2017 (gmt 0)

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



The problem is every single page I use it on has to sit in the main directory.

See topr8's illustration. The directive "include" means include from the present directory. Its usefulness is pretty limited. The directive "include virtual" means use a specified site-absolute filepath. That's the one you want.

Pro tip: If you don't currently have an /includes/ directory, create one for this purpose--but call it something else. This will keep malign robots from snuffling around requesting things like standard WP names.

You do not need to change all URLs--let alone all filenames--to .shtml. Just put this line in your config or htaccess:
AddOutputFilter INCLUDES .html

This is the most practical way if everything is to have includes. If you're only using them in selected directories, the X-Bit Hack is better.

Incidentally...
Well my site, which I have been hand coding since the late 90s, (don't laugh, it works for me.)

Anyway the thing has grown into a monster. Some time ago I learned how to include a bit of SSI just for navigation.

Good for you. It's heartbreaking when someone whose only website experience is with some popular CMS comes by asking plaintively how to, for example, add an image, or how to change a margin on just one page. SSIs are a great introduction to a very fundamental concept: What the user sees may not be exactly what's in the html file on the server. Your next step is to learn two or three words of php, and then just watch how much fun you'll have ;)

Artmaker

12:42 am on Mar 7, 2017 (gmt 0)

5+ Year Member



here it is right off my index page
<!--#include file="navigation/index"-->

note; the actual navigation page IS located within a navigation folder. But pages I actually include that on cannot be within a sub folder. That's when it stops working.
Now if this is just the way it has to be fine. I may have a directory that scrolls to China, but if that's the only way fine. Be so much easier if I could build all my store stuff in a store folder though.

"how are you including the include in a page….

The page the included file is on, must end in shtml and must be in the main directory.

(btw. apache or iis)" … Not a clue. Apache sounds familiar but honest, not a clue what that means.



"Your next step is to learn two or three words of php, and then just watch how much fun you'll have ;)" hahaha… my daughter is on my case to learn more code. I just no longer have the patience to learn an entirely new language. (It's what that is.) I know HTML well enough, been building my site with basically a text editor for years. Yes it's dated…. BUT it works. And it works on any browser, on any device. (minus the nyfty mouse over java script.) Unless it's changed, search engines hate long winded scripts too. Which for a site I only hand to people, wanna see what I do go here, it doesn't matter. BUT when I open a shopping section it will have to be more SEO friendly.
(Mind you, and I'm quite proud of this. My page with everything I've made so far has shown up on the top ten of google and several others for years now. And that's without me even trying. So I must be doing something right.)




[edited by: not2easy at 1:11 am (utc) on Mar 7, 2017]
[edit reason] see charter [/edit]

lucy24

1:32 am on Mar 7, 2017 (gmt 0)

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



I just no longer have the patience to learn an entirely new language.

The beauty of php is that it has a very, very shallow learning curve. You can learn just enough to do one thing, and then later on you learn how to do a second thing, and still later a third thing. Each time, you just add one or two words to your vocabulary. You don't have to built up a whole fluency before you're able to do anything at all.

See above about "include virtual".

Apache sounds familiar but honest, not a clue what that means.

Isn't SSI specifically an Apache function? Other servers can do the same thing, but it would be called by a different name.

tangor

1:43 am on Mar 7, 2017 (gmt 0)

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



I love SSI. Set the filehandler globally for all files (examples listed above are for apache. IIS has a version very similar, PHP has a line that operates the same way) and go from there.. Includes appear in various codes ... knowing the concept of "include this x into that y" is all it takes.

Artmaker

1:53 am on Mar 7, 2017 (gmt 0)

5+ Year Member



Well one more forum I tried today suggested CSS…. My site IS very table heavy. I know that's dated, and I get why but…. dang. It works.

So… what little I know of CSS (and it's very little) is that this is simply a way to pre set styles. Meaning colors, fonts, text size etc. Yes? No?
Not sure that would do anything like a server side include.

PHP huh? hmmmm. Dang, I might have to chip some rust of my brain.

Artmaker

2:00 am on Mar 7, 2017 (gmt 0)

5+ Year Member



Well forget it. I googled php include virtual… found a few pages supposedly to teach this. I am SO LOST!
Here. [php.net...]

Ya know, one guy showed me how to do SSI in one very short paragraph. It's not at all difficult.
This page (and a few more like it) is full of geek speak.

I need SPECIFIC this is how to do this instructions. I DO NOT have the time or patience, to figure out code anymore.

When I see the following? May as well be speaking Martian to me.

$DO_PARSE = in_array( $frequest_ext, $chk_exts );
if( $DO_PARSE )
{
$tmpfname = tempnam( $doc_framework.'tmp', 'aj_' ).($frequest_ext? ('.'.$frequest_ext) : '');
if( ($to_parse=@file_get_contents($doc_frequest))===FALSE )
$to_parse="404";
$tmpvname = str_replace( $docroot, '', $tmpfname );
$tmpvname = str_replace( '\\\\', '/', $tmpvname );
// - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Do processing of data stored in $to_parse
// - - - - - - - - - - - - - - - - - - - - - - - - - - -
$to_parse = striptags( $to_parse );

// - - - - - - - - - - -


HUH?

NickMNS

2:15 am on Mar 7, 2017 (gmt 0)

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



<!--#include file="navigation/index"-->


I may be wrong here but I read this as the index file is located in the navigation folder which is a sub-folder of the current folder. Therefore if you move this page to any other folder it will not work unless it also has a sub-folder navigation in it.

What you want is "/navigation/index" which tells the server to look in the root folder for the navigation sub-folder, regardless of what sub-folder the page is in.

Artmaker

3:18 am on Mar 7, 2017 (gmt 0)

5+ Year Member



Ok, here. I was told by my web host, EVERYTHING I do has to be in the public.html folder. That's the only one I go into. (Wish I could post a screen shot here.)
In there, I actually have several folders for navigation. Different sections of the site have different nav folders.
BUT… actual pages of my website ALL MUST be located directly in the public.html folder. Not in a sub directory for the SSI to work.
SO when I look at my file manager, I first go into public.html… then I have a stack of folders. Several of these navigation folders, images I can sort into folders, and other assorted junk.
BUT any page on my site, example.com that I want to use one of my SSI navigation things on, has to be on it's own in the public.html folder. AND if I have that included file it must end with .shtml

My site, over time has grown into a beast. Paintings alone has three sections and each section links to pages to individual paintings. Then there's a pencil section, graphics sections…. photography…. and more. Again, my little website has grown into a monster. RE doing it will be a nightmare. My thought was leave it along, put a sort of split right on my index page. Portfolio of past work go here, to shop go here. Just to make my life easier, ALL the shop stuff I'd put into a STORE folder. And if at all possible, sub folders within that. My lofty plans to open a shop which will no doubt consist of many more sections and pages. Possibly twice as much as I have on there now. The last site I sold on I had over 500 listings. So figure another 500 pages in time. Likely more. So it might be example.com/store/blue/widgets/stripes.shtml IF that can be done and use SSI on the page. I'm guessing not. Which would mean a whole lot of pages all in one long list that might look like example.com/storebluewidgetsstripes.shtml And see how that just looks like crap? Does to me. Also it will be so much easier to find each page as I need to mark something sold and change it around a bit.


Once I get rolling this won't be as hard. Save one page as my template, insert images, change text, tags etc… no more difficult than it was to list on a pre made site. It's working out a few little issues, and navigation is my biggest pet peeve on other sites. But any time you add 500 pages, there has GOT to be a way to do this simple. SSI fit the bill. All I need now is a way to use it, or something similar, and yet be able to organize my files better than one huge long list.


Even if I never get into PHP or CSS and keep my dated table method, one can't argue that it still works. I haven't found a browser yet that can't view my site. Now small devices it's a bit of a pain.
So on top of figuring out IF and HOW to get my navigation to work from within a sub folder, onto a page also in that sub folder, there is the question of do I want to attempt to find a way to make the content on the page fit into your hand? I'm leaning on the no side of that. (Based on what others have told me and my own personal shopping preferences. I can't see squat on my phone. Rather shop on a big screen.)

It's getting late, sorry if I rambled on too much.


[edited by: not2easy at 5:08 am (utc) on Mar 7, 2017]
[edit reason] Please read the charter [/edit]

tangor

3:42 am on Mar 7, 2017 (gmt 0)

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



Don't over think this! If you are on an apache host then all answers you need are noted above. Insert the handler directive into htaccess and all html files will look for includes and all your shtml files will still work the same way as they always have.

Marshall

5:22 am on Mar 7, 2017 (gmt 0)

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



<!--#include file="navigation/index"-->

Is this not an ASP include?

lucy24

5:40 am on Mar 7, 2017 (gmt 0)

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



This is all you need to know:
<!--#include virtual="/includes/header.html" -->

replacing /includes/ with some sneakier name that robots won't guess, and you can fill lthe directory with as many different files as you like. (And later on you can include php files as well. Yup, you can include snippets of php into an html document.) The magic word is "virtual". The /includes/ directory is parallel to any and all publicly accessible directories on the site as it presently exists-- /forums/ or /blog/ or /images/ or whatever you've got. But you don't want robots wandering around requesting it by name; that's why you call it something else.

And, oh criminy, tables for layout? No CSS? No, really, that's too much. Never mind about php for now; you've absolutely got to get some stylesheets in place. Otherwise you're saying the same thing over and over again on every page. There are certain words that should never occur in any html in the present decade, or indeed the present century--words like "bgcolor" or "font" or "cellpadding" or ... oh, what a list.

Hey! Why not go to HTML 5 while you're at it? Wait, come back, you don't need to change anything in your existing HTML. Just update the DTD. Er, you do have a DTD at the top of each page don't you? :)

Artmaker

3:29 pm on Mar 7, 2017 (gmt 0)

5+ Year Member



GM Lucy (and everyone attempting to help.)

First is it at all possible to convert my site now with CSS? I was thinking not. But I know tables are dated. Have been for awhile. Again if all I do is tell someone go here, it never mattered. It will with a shop, which is why I'm here. I want to build that side of things right. (BTW… many of my main site pages are headed for the trash heap. That might help.)

Ok, first off, is there a tutorial on JUST the bit of PHP I need to replace or alter my SSI for navigation purposes only? Every time I google PHP tutorials my head starts to explode.

HTML5 ? (some small changes I have known about, such as getting rid of caps in code. As I alter things I've been tweaking that.) Don't know anything more though.

And what is DTD? Sounds like insecticide. Oh wait, that's DDT. lol.

Artmaker

3:59 pm on Mar 7, 2017 (gmt 0)

5+ Year Member



HEY. Reading through the beginner section of a CSS tutorial…. yea with months of practice I could get that.

BUT…. what about a drag and drop website builder? I'm much more a visual person than a coder. Anyone have experience with these?
I'm still reading up but there's one that looks interesting.

thoughts? Oh man, if I could just create a page by dragging things in place, and have some tool generate the code, I'd be one happy camper. Is that possible?


[edited by: not2easy at 7:50 pm (utc) on Mar 7, 2017]
[edit reason] Please Read the Charter [/edit]

NickMNS

4:11 pm on Mar 7, 2017 (gmt 0)

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



For tutorials (CSS, HTML5, PHP, Bootstrap) you should checkout w3schools.com if you haven't yet.

A website builder could be a good solution for your needs, in my experience they are good for small simple sites but when things expand, and you begin to have problems they become impossible to maintain.

Given that all this is because you want to add an online store you should consider something like Wordpress that has e-commerce pluggins like Woo-commerce. This will allow you to get all the functionalities required to conduct on-line transactions with very little work.

Artmaker

5:24 pm on Mar 7, 2017 (gmt 0)

5+ Year Member



Ug, yes I have looked. I just really really don't want to stuff code into my head anymore. It's about as much fun as algebra class. (the only class I ever flunked.) It's why I've been putting this whole project off for too long. I just got a new lathe though. Will be making more stuff. No place to sell it. I NEED to fix my aging broken down site. It's already out there. Time to put the thing to work for me.

Been reading reviews on drag and drop builders. ALL have drawbacks. (Less than me learning CSS, PHP, HTML5, Bootstrap what ever that is. Months of hair ripping while I try to find the dot out of place making it all not work. yea… no.)

Anyway this one doesn't look too bad.<snip>
I just shot sales a long winded set of questions. (Good way to test support, always. Even if I know the answers.)
They do have a long list of how to videos. I watched a few already. Very well done.
I might just do this. 80.00 to just buy the thing. Gives one year of support. Should be all I need. This might also solve the issue of should I go mobile friendly or not. It does it for me.
One of my questions though is should the user NOT want the mobile friendly version can they request the full size even if on a phone. I kinda doubt it but that would be a good option to have. Especially if my webhost's stat tracking can pick up who set it to what and on what device.

I did look, this offers ecommerce. (though pay pal does that for free. I have already practiced adding a buy it now button. Not at all difficult.)
Another question I asked them…. and will here too
Once an item sells out, is it possible to have the page automatically change to "sold out, want one like it? Contact…." And leave the page live. (Google hangs onto stuff forever. I HAVE made sales from people finding images of stuff sold already.)

[edited by: not2easy at 7:48 pm (utc) on Mar 7, 2017]
[edit reason] Please Read the Charter [/edit]

lucy24

6:42 pm on Mar 7, 2017 (gmt 0)

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



About CSS .... Think about something really basic like your site's overall background color. That's, er, assuming it isn't all black on white. Right now every single page has something like
<body bgcolor = "#EEEEEE">
and then if you ever decided to change the color* you'd have to edit every single one of your hundreds of pages. Instead, your <head> section should contain a line something like
<link rel = "stylesheet" href = "/mystyles.css">
and then you make a single document called mystyles.css containing the line
body {background-color: #EEEEEE;}
so everything looks the same. Individual documents may contain a supplemental piece, still in the <head>, that goes
<style type** = "text/css">
{blahblah}
</style>
where you set things like a shared style for every h3 or every table-cell ;on that particular page (if it's different from your sitewide default).

I realize you are thinking that all you asked was a simple question about Server Side Includes and now everyone is jumping in and yelling about PHP and CSS and other stuff you don't want to hear about. But honestly, once you've done it you'll never want to go back. And, like your includes, it only has to be done once.

If you've got questions about ecommerce, you'll probably have better luck if you go next door to the ecommerce subforum where people*** have all the answers.


* Over the past 15 or so years, my personal website has grown lighter and lighter. It started out something like #ABF and by now it's at #CDF in most areas. “How the heck did I ever read that? It’s black-on-black!”
** The 'type = "text/css"' is technically superfluous, because no other style languages ever came into use, but it does no harm. And omitting it gives me the fantods.
*** Not me. Other people.

Artmaker

7:05 pm on Mar 7, 2017 (gmt 0)

5+ Year Member



I do understand. I read the first beginner chapter on CSS this morning.

I'm leaning more and more on just buying a drag and drop thing. Now my web host answered me right away. (always does.) He'll walk me through uploading. It's literally been years and years since I used his FTP thing.

Still waiting on a reply from the company selling it. And no answer is a deal buster. Companies who don't support what they are selling aren't worth my time. I'll find another one first.

SO guess this is all on hold until I find a proper tool. I really can't see hand coding this monster anymore. Fell too far behind. It's just overwhelming.

lucy24

9:14 pm on Mar 7, 2017 (gmt 0)

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



It's literally been years and years since I used his FTP thing.

How do you ordinarily upload new content?

I really can't see hand coding this monster anymore.

I don't see anything wrong with hundreds of hand-rolled pages. More power to you. Really. (Full disclosure: I've got hundreds of hand-rolled pages myself, so what else am I going to say.) But it has to be intelligently hand-rolled. If three different pages say exactly the same thing, then that “same thing”--whether it be format or navigation or even content--belongs somewhere other than in each separate page's HTML.

If you haven't already got one, go find a text editor that lets you find-and-replace across multiple documents. Combine this feature with some carefully constructed Regular Expressions, and you will be able to make massive sitewide changes in one fell swoop.