Need PHP Includes to work on site

General ShopSite user discussion

Need PHP Includes to work on site

Postby jontaco » Wed Feb 02, 2011 6:06 pm

Hi,

I am trying to get PHP, particularly PHP includes, to work on my Shopsite web pages.

First, I placed a PHP include at the top of my shopping cart page, which as I notice is a CGI page. I'm not sure how CGI can be configured to work with PHP on the server, I know more about PHP than I do CGI.

Here is the page:
http://www.mulberrystreetgifts.com/cgi-bin/sc/order.cgi?storeid=*1ab6811aa1049d2503ce7c8f753af0&function=show

View source and you will see <?php include("http://www.mulberrystreetgifts.com/cgi-bin/sc/templates/includes/header.php"); ?> at the top.

This does not work on this page.

There is also the issue of PHP includes not working on any other pages, such as:

http://mulberrystreetgifts.com/store/about.php

I even tried looking at phpinfo.php:

<?php

// Show all information, defaults to INFO_ALL
phpinfo();

// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);

?>

and noticed the server is running PHP Version 5.2.14.

I know a bit about building an .htaccess file also if that might be a possible solution.
Any suggestions?

Thank you,
Jonathan Wright
jontaco
 
Posts: 39
Joined: Sun Apr 20, 2008 8:05 pm
Location: Huntsville, AL

Re: Need PHP Includes to work on site

Postby c.wagner » Fri Feb 04, 2011 10:58 am

My understanding of PHP Include it that it requires SSI (Servier Side Includes) In order to use SSI on an Apache web server the file extension needs to be .shtml. Since the ShopSite checkout generates pages have the extension .cgi this will not work for you. It would however work for you in the static pages ShopSite generates. What is in the header.php file that you are trying to include anyway? There are likely better ways to try to accomplish what you are trying to do.

If the header.php file doesn't need to be dynamically generated by the server it would be better to use the --[ INCLUDE ]-- function of ShopSites template language.

Chris
c.wagner
 
Posts: 17
Joined: Fri May 28, 2010 9:23 am
Location: Norfolk, VA

Re: Need PHP Includes to work on site

Postby jontaco » Fri Feb 04, 2011 7:58 pm

Here is my site: http://www.mulberrystreetgifts.com/store/index.php

I have used php includes on my web site once before, and on my regular pages, like index.php.
I have read that somehow and some way, CGI pages can read PHP, but CGI is beyond my scope.

Here is a basic PHP include:
<?php include("menu.php"); ?>

I've used .shtml before, which I might consider.

I have also considered using shopsites include statements [-- include --], which is what I may do, but the only thing is that this shopsite code is not very portable if I ever choose to move my web site to another server or host.

Here is a better question. When you create a shopping cart template in shopsite, is it a priority to include the order page template, confirmation template, etc. all at once? For example, my custom shopping cart template looks like this:

[-- DEFINE ShoppingCart --]
...
[-- END_DEFINE ShoppingCart --]

[-- DEFINE Shipping --]
...
[-- END_DEFINE Shipping --]

[-- DEFINE Confirmation --]
...
[-- END_DEFINE Confirmation --]

[-- DEFINE ThankYou --]
...
[-- END_DEFINE ThankYou --]

[-- DEFINE ThankYou_Email --]
...
[-- END_DEFINE ThankYou_Email --]


This gets really really long, when you consider I have created my own template for the header, navigation and footer of my site. Includes would significantly reduce this custom template.
jontaco
 
Posts: 39
Joined: Sun Apr 20, 2008 8:05 pm
Location: Huntsville, AL

Re: Need PHP Includes to work on site

Postby c.wagner » Fri Feb 04, 2011 8:34 pm

Look into using Shopsites --[Include]-- tag. I think it will solve all of your problems. ShopSite cgi generated pages will not run your PHP Include code.

To organize your cart template build it like this:
Code: Select all
[-- DEFINE ShoppingCart --]
     [--INCLUDE shopping_cart PROCESS --]
[-- END_DEFINE ShoppingCart --]

[-- DEFINE Shipping --]
     [--INCLUDE shipping PROCESS --]
[-- END_DEFINE Shipping --]

[-- DEFINE Confirmation --]
     [--INCLUDE confirmation PROCESS --]
[-- END_DEFINE Confirmation --]

[-- DEFINE ThankYou --]
     [--INCLUDE thank_you PROCESS --]
[-- END_DEFINE ThankYou --]

[-- DEFINE ThankYou_Email --]
     [--INCLUDE thanks_email PROCESS --]
[-- END_DEFINE ThankYou_Email --]


Then build each one of the include files for each separate component

Chris
c.wagner
 
Posts: 17
Joined: Fri May 28, 2010 9:23 am
Location: Norfolk, VA

Re: Need PHP Includes to work on site

Postby jontaco » Fri Feb 04, 2011 8:57 pm

That sounds easiest. thanks.
jontaco
 
Posts: 39
Joined: Sun Apr 20, 2008 8:05 pm
Location: Huntsville, AL

Re: Need PHP Includes to work on site

Postby adsol » Mon Feb 14, 2011 3:02 pm

You can get the PHP to run but only on the SS generated HTML pages.

To get this to work you would include your php code in the pages / product templates. SS should skip over the php code. You must then go to every SS page / product and name the filename to -.php instead of -.html.

Essentially you are making SS create php pages.

The only place this will not work is on dynamic pages such as the search and order.cgi pages.

Only other way to get the code to run on all the pages is to use server side includes or ajax.
adsol
 
Posts: 15
Joined: Tue Mar 10, 2009 1:28 pm


Return to User Forum

Who is online

Users browsing this forum: No registered users and 141 guests