Jump to content

Include php inside DIV in shtml


FreeBenzine

Recommended Posts

Hello,

My page has several html includes. The index page with html does not work, and had to be made shtml to work. Now i need to include php inside a DIV of the shtml file. The include php works quite ok with html but fails with shtml. Could you kindly give me advice how to include php inside a DIV of shtml?

Tim

Link to comment
Share on other sites

One thing you could try -- assuming you are running a Linux based server, not Windows -- is to add a couple lines to your .htaccess file that tell the server to process .shtml files as PHP (which should allow you to keep the .shtml extension but still have the server process PHP)

 

This has more info: http://www.kavoir.com/2009/01/php-run-html-as-php.html

 

However, I'm not sure if there are any security related issues with doing this (though I don't think so?) and I'm not absolutely sure that .shtml includes will still work. If it doesn't work, you could always switch out .shtml includes for PHP includes instead.

Link to comment
Share on other sites

Hi,

I have several DIV elements and I am mainly calling html includes inside the DIV elements. In some occasions I need to use php includes in some DIVs. Here is my index file, I hope that it is understandable. Comments will be welcome. The index file when saved as shtml works fine as long as there are only html includes. If I have php includes it does not work. Changing the extension to php allows the php include to work but the html includes do not work. Any suggestions will appreciated. Thanks in advance.

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>

<title>Go Global</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<link href="GGStyleSheet.css" rel="stylesheet" type="text/css">

</head>

 

<body>

<div id="container">

 

<div id="TopTopDiv">

<!--#include virtual="IncludeTop.html" -->

</div>

 

 

<div id="LeftDiv">

 

<div id="LeftmenuDiv">

<!--#include virtual="IncludeLeftMenu.html" -->

</div>

 

<div id="BottomofMenuDiv">

<!--#include virtual="IncludeBottomofMenu.html" -->

</div>

</div>

 

<div id="CentralDiv">

<?php include("test.php"); ?>

</div>

 

<div id="RightDiv">

<!--#include virtual="IncludeRight.html" -->

</div>

 

<div id="FooterDiv">

<!--#include virtual="IncludeFooter.html" -->

</div>

 

</div>

</body>

</html>

Link to comment
Share on other sites

You will have to change th efilename extension from .shtml if you want the PHP "includes" to work. Either change the filename or change it by using .htaccess file as falkencreative suggested.

 

Then any shtml code won't work as you will be mixing shtml and php so you need to use one or the other.

Link to comment
Share on other sites

Then any shtml code won't work as you will be mixing shtml and php so you need to use one or the other.

 

Go with PHP as you will many more options in terms of what you could do with that page. SHTML is a throwback to an earlier time in the Web ... kinda like phone operators.

 

... No longer needed.

 

:)

 

Stefan

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...