PHP and ShopSite Integration

This is an archive of old posting to the User Forum

PHP and ShopSite Integration

Postby Dennis Moore » Mon Apr 22, 2002 4:42 pm

What are the fundamentals in integrating ShopSite with PHP? Someone
mentioned to me that this was possible.
Dennis Moore
 

Re: PHP and ShopSite Integration

Postby loren_d_c » Mon Apr 22, 2002 7:21 pm

The basic requirement for a PHP page is simply that it be named with a
..php extension, which is easy enough in ShopSite. What you do after that
depends on how complicated your PHP code is and what part of the page
you want it to interact with. If you just want to include a PHP footer,
then you could put the PHP include code in the Universal Footer (note
that this would then be on all of your pages, unless you turned off the
Use Universal Footer in the non-PHP pages). If you just want standar PHP
fields in other sections of the page, then you could place the PHP code
in the Text 1, Text 2, and Text 3 fields in the Page Contents. You could
also place PHP code in the Product Description and More Info Page text
field.

On the other hand, if you want to do something more complex like
interact with other page and product elements, then you would want your
PHP code in the custom template. For example, if you wanted to have your
product display an Out of Stock graphic instead of the usual order
button whenever the product is out of stock based on your own SQL
inventory database, then this could be accomplished with PHP code in the
product template (note that the page the product is assigned to would
have to have the .php extension for this to work).

I think you can even have pages with the .php extension and no PHP in
them, just plain HTML, although this probably increases your server load
unnecessarily because the webserver would need to inspect each document
for PHP code before serving up the page.

-Loren



Dennis Moore wrote:

What are the fundamentals in integrating ShopSite with PHP? Someone
mentioned to me that this was possible.
loren_d_c
 
Posts: 2571
Joined: Fri Aug 04, 2006 12:02 pm
Location: Anywhere

Re: PHP and ShopSite Integration

Postby Joseph Lundgren » Wed Apr 24, 2002 9:47 am

Greetings,

PHP is very easy to integrate into ShopSite, and even moreso if you know the
PHP language beforehand.

We recently converted one of our client websites to PHP. The problem was
that there were hundreds of pages, each with hard-coded links (using text3
on left side template) to foo.html (instead of foo.PHP, as they now would be
named) Did we want to manually edit each and every page to change the .html
extension to .PHP? NO! The solution was to write a simple .htaccess file
that would dynamically rewrite any request for a file named "foo.html" to
actually request the file named "foo.PHP". This solution assumes that your
server has Apache and mod_rewrite installed.

RewriteEngine On
RewriteRule ^(.*)\.html$ $1 [C,E=WasHTML:yes]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [S=1]
RewriteCond %{ENV:WasHTML} ^yes$
RewriteRule ^(.*)$ $1.html


There is no reason NOT to have every page end with a .PHP extension. The
PHP processor is extremely streamlined, and can easily handle all but the
most extreme cases (like, if you have dozens of pages open/close/manipulate
large databases (MySQL or otherwise) simultaneously) You could even change
the way apache views PHP and HTML more fundamentally by adding the following
lines to your .htaccess file (again, assumes you're running Apache.) This
makes it so that Apache will use the PHP module to process every page,
regardless if it contains PHP or not.

AddType application/x-httpd-php .html
AddType application/x-httpd-php .htm


As Loren suggests, and as Brandon Eley mentioned in a previous post, you can
integrate PHP into the custom template pretty easily. Check out his
excellent template at http://www.2bigfeet.com/template.php (I hope you don't
mind that I quoted your previous post, Brandon)


"Loren" <loren_d_c@yahoo.com> wrote in message
news:3CC4C52C.AC521566@yahoo.com...
The basic requirement for a PHP page is simply that it be named with a
..php extension, which is easy enough in ShopSite. What you do after that
depends on how complicated your PHP code is and what part of the page
you want it to interact with. If you just want to include a PHP footer,
then you could put the PHP include code in the Universal Footer (note
that this would then be on all of your pages, unless you turned off the
Use Universal Footer in the non-PHP pages). If you just want standar PHP
fields in other sections of the page, then you could place the PHP code
in the Text 1, Text 2, and Text 3 fields in the Page Contents. You could
also place PHP code in the Product Description and More Info Page text
field.

On the other hand, if you want to do something more complex like
interact with other page and product elements, then you would want your
PHP code in the custom template. For example, if you wanted to have your
product display an Out of Stock graphic instead of the usual order
button whenever the product is out of stock based on your own SQL
inventory database, then this could be accomplished with PHP code in the
product template (note that the page the product is assigned to would
have to have the .php extension for this to work).

I think you can even have pages with the .php extension and no PHP in
them, just plain HTML, although this probably increases your server load
unnecessarily because the webserver would need to inspect each document
for PHP code before serving up the page.

-Loren



Dennis Moore wrote:

What are the fundamentals in integrating ShopSite with PHP? Someone
mentioned to me that this was possible.
Joseph Lundgren
 

Re: PHP and ShopSite Integration

Postby loren_d_c » Wed Apr 24, 2002 11:13 am

Another thing to note is that in order to have the .htaccess file be
able to do a rewrite and AddType like this, you have to have
'AllowOverride All' (or perhaps someone knows what specific
AllowOverride option could be used to allow this besides all) in the
apache config file in the attributes for the Directory directive for the
directory the .htaccess file is in (or an ancestor of that directory).
For most people this shouldn't be a problem because the hosts have
probably already done this in order to allow them to password protect
directories on their sites, but I thought I should mention it because it
is not the default config on an apache webserver (default is
AllowOverride None which basically ignores .htaccess files).

-Loren



Joseph Lundgren wrote:
Greetings,

PHP is very easy to integrate into ShopSite, and even moreso if you know the
PHP language beforehand.

We recently converted one of our client websites to PHP. The problem was
that there were hundreds of pages, each with hard-coded links (using text3
on left side template) to foo.html (instead of foo.PHP, as they now would be
named) Did we want to manually edit each and every page to change the .html
extension to .PHP? NO! The solution was to write a simple .htaccess file
that would dynamically rewrite any request for a file named "foo.html" to
actually request the file named "foo.PHP". This solution assumes that your
server has Apache and mod_rewrite installed.

RewriteEngine On
RewriteRule ^(.*)\.html$ $1 [C,E=WasHTML:yes]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [S=1]
RewriteCond %{ENV:WasHTML} ^yes$
RewriteRule ^(.*)$ $1.html

There is no reason NOT to have every page end with a .PHP extension. The
PHP processor is extremely streamlined, and can easily handle all but the
most extreme cases (like, if you have dozens of pages open/close/manipulate
large databases (MySQL or otherwise) simultaneously) You could even change
the way apache views PHP and HTML more fundamentally by adding the following
lines to your .htaccess file (again, assumes you're running Apache.) This
makes it so that Apache will use the PHP module to process every page,
regardless if it contains PHP or not.

AddType application/x-httpd-php .html
AddType application/x-httpd-php .htm

As Loren suggests, and as Brandon Eley mentioned in a previous post, you can
integrate PHP into the custom template pretty easily. Check out his
excellent template at http://www.2bigfeet.com/template.php (I hope you don't
mind that I quoted your previous post, Brandon)

"Loren" <loren_d_c@yahoo.com> wrote in message
news:3CC4C52C.AC521566@yahoo.com...
The basic requirement for a PHP page is simply that it be named with a
.php extension, which is easy enough in ShopSite. What you do after that
depends on how complicated your PHP code is and what part of the page
you want it to interact with. If you just want to include a PHP footer,
then you could put the PHP include code in the Universal Footer (note
that this would then be on all of your pages, unless you turned off the
Use Universal Footer in the non-PHP pages). If you just want standar PHP
fields in other sections of the page, then you could place the PHP code
in the Text 1, Text 2, and Text 3 fields in the Page Contents. You could
also place PHP code in the Product Description and More Info Page text
field.

On the other hand, if you want to do something more complex like
interact with other page and product elements, then you would want your
PHP code in the custom template. For example, if you wanted to have your
product display an Out of Stock graphic instead of the usual order
button whenever the product is out of stock based on your own SQL
inventory database, then this could be accomplished with PHP code in the
product template (note that the page the product is assigned to would
have to have the .php extension for this to work).

I think you can even have pages with the .php extension and no PHP in
them, just plain HTML, although this probably increases your server load
unnecessarily because the webserver would need to inspect each document
for PHP code before serving up the page.

-Loren

Dennis Moore wrote:

What are the fundamentals in integrating ShopSite with PHP? Someone
mentioned to me that this was possible.
loren_d_c
 
Posts: 2571
Joined: Fri Aug 04, 2006 12:02 pm
Location: Anywhere


Return to User Forum Archive

Who is online

Users browsing this forum: No registered users and 20 guests