SSI File vs PHP Includes

Must all my HTML pages be converted to PHP for SSI includes to work in them?

I’ve created a page with a header that includes a navbar and moved it to an include file (incl-header.html) and selected SSI File as the type. I can import it into my existing html files and the include displays nicely in Design View. But when I open the converted pages in a browser, the include does not display. In code view, the include line is commented out. So am I doing something wrong or do I ned to covert to PHP?
Here is what is placed on the page:

<!--#include file="incl-header.html" --> …does not display the include

If I convert the page to a PHP and select PHP Include as the type, the include displays on the page in the browser and works well:

<?php include 'incl-header.html';?> …displays the include

Try<!--#include file="/incl-header.html" -->

This will make sure it is read as an absolute path. This may fix the issue.
SSI might not be enabled on your server also. I’ve never personally used ssi on a site yet, always php, but on sites I’ve edited that used it - these have been issues I’ve seen.

2 Likes

It requires that your server supports SSI and has it enabled, for apache you need to have mod_include enabled. http://httpd.apache.org/docs/current/mod/mod_include.html

For the PHP includes you must indeed convert your page to a PHP file so that it is handled correctly on your server, which of course needs to have PHP installed.

2 Likes

Thanks Patrick. I converted my html pages to php and got the SSI to work.

I did some reading on SSI files vs php includes and also this thread. Am I correct to assume that a server set up for server side includes will automaically serve shtml files as includes where set up as such? And that any other includes such as SSI without this setup and php on apache will need the file to have the php extension? html extensions will not work?

How does the server know files should be served using SSI vs PHP includes?

I’m new to this and haven’t used includes since many years ago on Dreamweaver with the very very old webassist stuff.

I tried building Single page apps using conditional regions in of App Connect but they just get too big and app structure and it’s functions just stops working since the app structure get’s too cumbersome and complicated.

I hope SSI can be a solution to this. anyone else has a method for building single page like apps in Wappler/App connect/Server Connect?

It all depends on your server configuration. Normally SSI includes are enables on pages with the extensions .shtml, .stm and .shtm. On IIS it is also enabled for .asp. PHP includes are default enabled for pages with the extension .php. To use it the modules must be installes and enabled. You can also configure the server to handle SSI on .html pages, default this is not enabled and the server serves the html files as they are without processing.

1 Like

@patrick Thanks for feedback. Tried it with .html and could not get it to work in spite of having the needed code in .htaccess. Reverted to php include for now. Is there major difference in the sense that php refreshing all elemente of DOM vs just requested elements with SSI as a javascript based app would do, or is performance more or less the same? Why would one use ssi over php and aalso virtual vs normal?

As Patrick said, SSI is included in Apache and you would think this would make it faster. With CGI, Apache launches a new PHP process which is slower. However, mod_php makes PHP a module of Apache which keeps PHP internal - or not an external process.

So I don’t think speed really matters in the end. I think PHP includes is much more manageable and easier to keep a hold of. It also doesn’t require a bunch of additional work to make it happen. I don’t use SSI much, and I’m not clear on your virtual vs. normal question. But I believe the difference between virtual and normal is that virtual just means the file isn’t in the directory of your website. So maybe the include file is on your server root and not in the website directory.

1 Like

Hello, I am trying to build a web portal using Wappler and I am stuck trying to use SSI. I have created an html page with content and when I move the menu header to an include file it displays fine in Wappler but doesn’t appear from the web server via the browser. I am using Microsoft IIS and Classic ASP and this is a frequent thing I do without issue in Dreamweaver.

I can see that by default a new page is always created by Wappler as an html file and when I send the include information to a separate file it simply creates a text file.

I can see why this fails in IIS Classic ASP mode as IIS does not support includes on non-ASP pages but I cannot find any way via Wappler to generate either the original page as an ASP page or indeed the include file either.

Is it a case of simply adding the ASP directive to the page and converting the filetype and name to ASP outside of Wappler?

I also am trying and failing to duplicate an entire page so I can make small modification on the copy but can find no way to do this in Wappler so in this case is it a case of creating a new empty file then copying the source code from the first page?

Sorry if this has been answered elsewhere as I have searched for a solution with no luck!

When using an SSI, you need to have the proper extension for the document. For ASP have a look at https://www.hitmill.com/programming/asp/aspSSI.html which mentions: will have to use the .asp extension

Hi Ben, thanks for that, As a long term classic asp developer I was aware that is the case but my key issue is that it does not seem possible to create a new .asp page programatically in Wappler as it only creates .html by default and an asp page would need an asp directive at the top of the script. It looks like Wappler has no provision to do this so the only way seems to edit the filename and page code outside of Wappler or am I wrong?

Easy to miss but there is a menu for doing it

image

That is exactly what I have been searching for thanks so much! I think it might have been days to weeks before I spotted that. It might be worth investigating whether it would be worth repeating this function under the Local Files section on the left?

ahh! I seem to have run into another issue now. Created new asp page using the feature top right as you described. But when I load this page I lose design view and App Structure so it seems I can only edit the document in code view and that’s about it with no access to add sections, add page functions, add data areas etc. which means that in reality I have little more than I would have in any text editor?

Is this to do with the local server unable to parse .asp?

Screen with html file

Screen with asp file

Odd behaviour now. I closed the project and opened a different project then closed that and reopened this and hey presto the design view and app structure re-appeared. I must be doing something not quite correctly?

Anyway will try to continue now. Thanks for your help and interest.

Make sure you have added the App connect framework to the new page, it looks like it has not been added?

Hi, I think I broke it by copying the html code to the new asp page from the html one so Wappler didn’t pick up the linked files etc until I restarted. This brings me back to my other question, is it possible to make a duplicate copy of an entire page with a new filename and even a different file extension via Wappler?

You can use the ‘Save As’ option. Itt is located in yet another hard to notice spot. The three dotts at the top right of the UI.

Thanks Brad, I’m beginning to think it would be a good idea to click on every icon in the interface one-by-one to find out what they do!

If anyone authors a complete ground up paperback Wappler manual any time soon I will be the first to buy one…

Most of my reading is in bite-sizes pieces covering only one topic at a time so it’s necessary to google around to find how to’s on the less obvious stuff.

That said it’s an impressive program.

Who knows what the future will bring :wink: