OSCOMMERCE SUPPORT CALL 702-453-3332

 

Help - Search - Members - Calendar
Full Version: [contribution] Simple Template System (sts)
osCommerce Community Support Forums > osCommerce Online Merchant v2.x > Contributions / Add-Ons > Templates and Images
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90
DiamondSea
Simple Template System (STS) README.txt v1.3
Contribution Author: Brian Gallagher @ DiamondSea.com
Contribution Author Email: brian@diamondsea.com

-----------------------------------------------------------------------------
WHAT IT DOES:
-----------------------------------------------------------------------------
Lets you create simple HTML templates to customize the look and feel of OSC.

You simply create an HTML page that looks the way you want it to and put in
placeholders for the various elements wherever you want to position them.

For example, you would put "$cartbox" wherever on the page you want the
Shopping Cart box to appear. Put "$categorybox" where you want the Categories
box to appear. Put "$content" wherever you want the main page
content (the central part where all the magic happens) to appear, etc.

It does this by changing only a few /catalog/includes/ files, leaving all
other files untouched, making it easy to add other contributions later.

-----------------------------------------------------------------------------
BONUS FEATURES: Simple HEADER TAG CONTROLLER Integration
-----------------------------------------------------------------------------
This contribution also allows you to use WebMakers.com's
Header Tag Controller contribution without having to modify every file on
the system. Just copy the Header Tag Controller's include files into place
and STS will automatically add them to all pages without having to modify
every PHP script in the /catalog/ directory.

STS will auto-detect if Header Tag Controller is installed and use it if
available.

-----------------------------------------------------------------------------
HOW TO INSTALL:
-----------------------------------------------------------------------------

Installation Instructions are found in the readme.txt file included in the package. Please read the readme.txt file for a list of installation instructions, new features, new variables and other enhancements to STS.


-----------------------------------------------------------------------------
HOW TO USE:
-----------------------------------------------------------------------------
Just modify the

/catalog/includes/sts_template.html

file to look however you want. Use stylesheet settings or HTML setting to
provide a custom look and feel to your site and arrange elements wherever you
like them.

-----------------------------------------------------------------------------
SUPPORTED TAGS:
-----------------------------------------------------------------------------
Here are the tags that are supported so far (more sure to come in later
versions):

$headcontent: Put this string in your <head> section so that it can insert
the dynamic head content and javascript on pages that require it. This will
probably require putting the $headcontent in the <head> section in the source
code. It's a pain to do it this way, but it was the only way I could get it
working. Sorry!

<!--$headcontent--> : You can use this commented format of $headcontent to
keep the word "$headcontent" from displaying in your web authoring software.

NOTE: Do not put <title>...</title> tags in your header. It will be added
as part of the $headcontent variable, along with the Description and Keywords
meta tags if you have the WebMakers.com's Header Tag Controller contribution
installed.

$cataloglogo: The OSC logo and link
$urlcataloglogo: The URL used by the $catalog logo.
$myaccountlogo: The MyAccount graphic and link
$urlmyaccountlogo: The URL used by the My Account function
$cartlogo: The Cart graphic and link
$urlcartlogo: The URL used by the Cart function
$checkoutlogo: The Checkout graphic and link
$urlcheckoutlogo: The URL used by the Checkout function
$breadcrumbs: The "Top > Catalog > whatever..." breadcrumbs text and links
$myaccount: The text version of "My Account" and link. Changes to "Logoff" if logged on.
$urlmyaccount: The URL used by the MyAccount function.
$cartcontents: The text version of the "Cart Contents" function.
$urlcartcontents: The URL used by the MyAccount function.
$checkout: The text version of the "Check Out" function.
$urlcheckout: The URL used by the "Check Out" function.

$categorybox: The Category box
$manufacturerbox: The Manufacturer box
$whatsnewbox: The What's New box
$searchbox: The Search box
$informationbox: The Information box
$cartbox: The Shopping Cart box
$maninfobox: The Manufacturer Info box (blank if not used on a page)
$orderhistorybox: The Order History box (blank if not used on a page, ie: use not logged in)
$bestsellersbox: The Best Sellers box
$specialfriendbox: Either the Specials box or the Tell A Friend box (depending on page viewed)
$reviewsbox: The Reviews box
$languagebox: The Languages box
$currenciesbox: The Currencies box
$content: The main content of the page (the middle of the page)
$date: The current date
$numrequests: The "XXX requests Since DATE" text
$counter: The page view counter
$footer: The footer output from footer.php
$banner: The banner output from footer.php

$sid: The string for the Session ID in the format "SessionIdVarName=WhateverTheSessionIdIs"


-----------------------------------------------------------------------------
DEBUGGING:
-----------------------------------------------------------------------------
In the /catalog/includes/application_bottom.php file you can see the
following settings (near the top of the file):

$display_template_output = 1;
$display_normal_output = 0;
$display_debugging_output = 0;

Display_Template_Output (the default setting) will cause it to display the
template versions of the pages.

Display_Normal_Output will cause it to display the non-template version of
the pages.

Display_Debugging_Output will cause it to display debugging information
showing all of the blocks of data that it is using and how it translates
them into template variables.

You can use any or all of the settings in any combination. If you have both
Normal and Template output, the Template output will be displayed first.

-----------------------------------------------------------------------------
REMOTE DEBUGGING:
-----------------------------------------------------------------------------
You can toggle the debugging options via URL options. You can use the
following parameters in your URL to turn on/off options from your browser

sts_template=1 Turns on the Template display
sts_template=0 Turns off the Template display
sts_normal=1 Turns on the Normal display
sts_normal=0 Turns off the Normal display
sts_debug=1 Turns on the Debugging display
sts_debug=0 Turns off the Debugging display
sts_version=1 Turns on Version Number display
sts_version=0 Turns off Version Number display

-----------------------------------------------------------------------------
SUPPORT:
-----------------------------------------------------------------------------

For support, please post to this thread.
DiamondSea
You can download the newest version of Simple Template System (STS) here:

http://www.oscommerce.com/community/contributions,1524

- Brian
DiamondSea
There are a couple great changes in STS 1.3:

Added Auto-detection and use of the WebMakers.com Header Tag Controller contribution. STS now manages the <title> and <meta> tags, so you no longer have to modify every php file in the catalog directory to support it.

Added a commented $headcontent variable. Use
CODE
<!--$headcontent-->

in your <head> section in sts_template.html and it won't show "$headcontent" on the top of your page in Dreamweaver or other editors. Note that you must put the tag EXACTLY as it appears above, with no spaces or anything else in the comment tags.

Changed template.html to sts_template.html to make it stand out and fit in with the new naming scheme. There are also new configure.php variables you need to set. See the Readme.txt for details.

Added a $sid variable. I'm not positive yet, but I suspect that this will be needed for some fancy sts_template.html layouts where you have image-map based menus.

Added a $title variable. You shouldn't use it normally, you should use the $headcontent or <!--$headcontent--> variable. But it's there if you need it for javascript or something.

Changed the file layout and naming system and internal variable names to be even easier to make future changes to the /includes/ files when working with other contributions.

Enjoy!

- Brian
speckados
This template system work fine on http pages. I've installed version 1.2

Just download now 1.3 for install.

But there a problem, with https pages.

Whe go to https for confirm buy, if system it's configured with https, $content show pages on https, and other $ ($cartcontents, $information, ..) show href with http links.

That produces a lot of windows alerts on IE and other browsers.
speckados
This template system work fine on http pages. I've installed version 1.2

Just download now 1.3 for install.

But there a problem, with https pages.

Whe go to https for confirm buy, if system it's configured with https, $content show pages on https, and other $ ($cartcontents, $information, ..) show href with http links.

That produces a lot of windows alerts on IE and other browsers.
speckados
std_display_output.php isn't on zip file on contribution.

Fail application.

Version 1.3
geizhals
thx for this great contrib - but how do i add for example infoboxes - newsdesk or other contribs ?

thx in advance
geizhals
DiamondSea
QUOTE (speckados @ Sep 15 2003, 04:08 AM)
This template system work fine on http pages. I've installed version 1.2

Just download now 1.3 for install.

But there a problem, with https pages.

Whe go to https for confirm buy, if system it's configured with https, $content show pages on https, and other $ ($cartcontents, $information, ..) show href with http links.

That produces a lot of windows alerts on IE and other browsers.

Did it work in the 1.2 version? I don't think I've changed anything that should have changed it between 1.2 and 1.3.

Do you have a URL that I can take a look at?

- bg
speckados
Sorry, for inconvenients.

My shop. not a fresh install of 2.2MS2... just install a fresh 2.2MS2 a nd work fine.

Sorry for the post and a lot of thanks for great work.

Just testing now with 1.2 version...
DiamondSea
QUOTE (speckados @ Sep 15 2003, 04:25 AM)
std_display_output.php isn't on v1.3 zip file on contribution.

Oops! My mistake.

I just uploaded STS v1.4 which has the sts_display_output.php file in it.

That's what happens when you try to package a contribution at 2:30AM! :-)

Incidentally, for Release-specific postings, I will use the Heart Icon on the message list to help flag general interest posts from support posts.

- bg
DiamondSea
QUOTE (geizhals @ Sep 15 2003, 06:47 AM)
thx for this great contrib - but how do i add for example infoboxes - newsdesk or other contribs ?

Short Version:

In /includes/column_left.php: Duplicate the code in column_left.php that you find around the require(BOXFILENAME) and make sure that the $sts_block_name has the correct name for the block ABOVE it. This is the name you'll use for the variable in the sts_template.html file.

NOTE: I moved ALL boxes into column_left.php to make maintaining it easier so you don't have to figure out which (left or right) file the boxes are stored in. If you want to put stuff in column_right it will work, but it's easier to just leave them in column_left.php.

In /includes/sts_display_output.php: In the Create custom boxes
section, add a new line like this:

CODE
$template['newsdeskbox'] = strip_unwanted_tags($sts_block['newsdeskbox'], 'newsdeskbox');


That should be all you need to do. In the above example, you can then use $newsdeskbox as a variable name in your sts_template.html file.

If you need more details, let me know.

- bg
MurrayM
This looks to be a terrific contribution. Is there a site somewhere that we could look at to see how an implementation works?
thanks.
j0ker
Super contrib helps a lot to change the look and feel of the standard osc, one small problem I seem to be having after update v1.4 I am unable to change the Logo image and name.
Here is the header code which I think is in header.php that needed changing? or am I wrong plz help.

<?php
/*
$Id: header.php,v 1.19 2002/04/13 16:11:52 hpdl Exp $

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright © 2002 osCommerce

Released under the GNU General Public License
*/

if ($messageStack->size > 0) {
echo $messageStack->output();
}
?>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td><?php echo tep_image(DIR_WS_IMAGES . 'adminlogo1.gif', 'Easypcs - Serious Solutions', '204', '50'); ?></td>
<td align="right"><?php echo '<a href="http://www.easypcs.co.uk">' . tep_image(DIR_WS_IMAGES . 'header_support.gif', HEADER_TITLE_SUPPORT_SITE, '50', '50') . '</a>&nbsp;&nbsp;<a href="' . tep_catalog_href_link() . '">' . tep_image(DIR_WS_IMAGES . 'header_checkout.gif', HEADER_TITLE_ONLINE_CATALOG, '53', '50') . '</a>&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'header_administration.gif', HEADER_TITLE_ADMINISTRATION, '50', '50') . '</a>'; ?>&nbsp;&nbsp;</td>
</tr>

Thx
DiamondSea
QUOTE (MurrayM @ Sep 16 2003, 12:47 AM)
This looks to be a terrific contribution. Is there a site somewhere that we could look at to see how an implementation works?

I'm working on one now, and building the features to make it even easier into v1.5 which should be out fairly soon. When I get a good demo site up I'll post a link to the site and the template page.

Anyone else got a site they've already done? Show us what you did!

- Brian
DiamondSea
QUOTE (j0ker @ Sep 16 2003, 03:23 AM)
Super contrib helps a lot to change the look and feel of the standard osc, one small problem I seem to be having after update v1.4 I am unable to change the Logo image and name.
Here is the header code which I think is in header.php that needed changing? or am I wrong plz help.

Glad you like it. There's even more cool stuff coming soon in v1.5 as I develop my site with it and add more features to make the design process simpler.

To answer your question, STS doesn't use the code from the header.php code for the image. In /catalog/includes/sts_display_output.php you can change this line:
CODE
 $template['cataloglogo'] = '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'oscommerce.gif', 'osCommerce') . '</a>';
 $template['urlcataloglogo'] = tep_href_link(FILENAME_DEFAULT);


However, a better solution would be to simply put your own <img> tag in the /catalog/includes/sts_template.html with your HTML editor like this:
CODE
<img src="/path/to/image.gif/" href="$urlcataloglogo" alt="Your Site Name">


You should use absolute URL's (ones that start with a slash) for your image src= values since OSC uses <base> tag to change the default page location which could confuse your browser otherwise.

This way you don't have to modify any of the PHP code, which is the design goal of this contribution.

Just for the heck of it, I will start using the smiley face (smile.gif ) icon when I post answers to questions, and heart icons for version/release information. Hopefully this may make it easier to scan through the threads looking for answers to your questions.

- Brian
HandCrafted
I love the template system, I had just installed 1.2 4 days ago.. it worked great..
I just hope it isnt a big deal to upgrade to 1.3.. it doesnt seem so, but I already customized some things sad.gif

Good stuff! Thanks for the contrib!!!!


Should i wait till 1.5 to upgrade?
DiamondSea
QUOTE (HandCrafted @ Sep 16 2003, 09:16 PM)
I love the template system, I had just installed 1.2 4 days ago.. it worked great..
I just hope it isnt a big deal to upgrade to 1.3.. it doesnt seem so, but I already customized some things sad.gif

Good stuff! Thanks for the contrib!!!!

Should i wait till 1.5 to upgrade?


I'd switch over to v1.4, just because it does some things better (such as being integrated with the Meta Tags Controller contrib), is better laid out and you really don't have to do much to upgrade other than copy the files in and add a couple more lines to the end of configure.php. And the template.html file name is changed to sts_template.html.

What have you customized? Anything in the files that STS modified? If not, you can just install the new files and update configure.php and you're done.

If you have modified the STS files, what did you do? If you changed them, it means that I'm not doing things right, as my goal is to not have a reason for anyone to have to change the code (except for adding boxes).

Actually, I'll fix that problem too, now that I've thought of it. :-) I'll add an sts_user_modifications.php (or something like that) where you can put in your custom code, so you put custom stuff in there without having to worry about getting it clobbered with the next version's updated files. Sound good?

Do you have a link you can post to the site and the template.html file so that the hungry masses here can see what people are doing with it (and how you're doing it)? smile.gif

- Brian
HandCrafted
Heya,

What i changed was adding the box's such as my Affliate box and a few others.. So i coded them in the way you had the rest of the boxes.. Not that its that big a deal.. but.. smile.gif

Thanks for the quick responce!!
j0ker
QUOTE (DiamondSea @ Sep 17 2003, 01:54 AM)
QUOTE (j0ker @ Sep 16 2003, 03:23 AM)
Super contrib helps a lot to change the look and feel of the standard osc, one small problem I seem to be having after update v1.4 I am unable to change the Logo image and name.
Here is the header code which I think is in header.php that needed changing? or am I wrong plz help.

Glad you like it. There's even more cool stuff coming soon in v1.5 as I develop my site with it and add more features to make the design process simpler.

To answer your question, STS doesn't use the code from the header.php code for the image. In /catalog/includes/sts_display_output.php you can change this line:
CODE
 $template['cataloglogo'] = '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'oscommerce.gif', 'osCommerce') . '</a>';
 $template['urlcataloglogo'] = tep_href_link(FILENAME_DEFAULT);


However, a better solution would be to simply put your own <img> tag in the /catalog/includes/sts_template.html with your HTML editor like this:
CODE
<img src="/path/to/image.gif/" href="$urlcataloglogo" alt="Your Site Name">


You should use absolute URL's (ones that start with a slash) for your image src= values since OSC uses <base> tag to change the default page location which could confuse your browser otherwise.

This way you don't have to modify any of the PHP code, which is the design goal of this contribution.

Just for the heck of it, I will start using the smiley face (smile.gif ) icon when I post answers to questions, and heart icons for version/release information. Hopefully this may make it easier to scan through the threads looking for answers to your questions.

- Brian

Thanks for the fix, as you can see I am new to php and osc but I am trying to learn.

Keep up the good work and thx
alliance
Hi all, this contribute is fantastic, but i do not understand how to change the box layout.
Can anyone help me, tnx all
DiamondSea
QUOTE (alliance @ Sep 17 2003, 06:14 AM)
Hi all, this contribute is fantastic, but i do not understand how to change the box layout.
Can anyone help me, tnx all

You can't change the box layout with STS. You'd have to change the stylesheet and/or the PHP script that creates the boxes depending on what you want to change.

- Brian
jajayao
great contrib! however, I can't seem to locate the
$display_template_output = 1;
$display_normal_output = 0;
$display_debugging_output = 0;

in the application_bottom.php file? Am I missing something? I have version 1.4 installed.

THanks
DiamondSea
QUOTE (jajayao @ Sep 17 2003, 09:40 AM)
great contrib!  however, I can't seem to locate the
$display_template_output = 1;
  $display_normal_output = 0;
  $display_debugging_output = 0;

in the application_bottom.php file?  Am I missing something?  I have version 1.4 installed.

THanks

It is located near the top of sts_display_output.php.

You can also control it from your browser by adding &STS_DEBUG=1 to turn on the debugging or other options (see the README.txt file in the contribution).

- Brian
SevenD
Thank you Brian, great contribution.

You can see STS 1.4 implementation in action on my demo site.
DiamondSea
QUOTE (SevenD @ Sep 17 2003, 02:29 PM)
Thank you Brian, great contribution.

You can see STS 1.4 implementation in action on my demo site.

Your Welcome! Your site looks great!

Can you post a link to your Template.html file so people can see how you set it up?

- Brian
SevenD
This is one example of sts_template.html (without right column). prewiew
Change the style.css for custom look.

QUOTE
<html>
<head>
<!--$headcontent-->
</head>
<body>
<table class="okvir" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr class="header">
    <td>$cataloglogo</td>
        </tr>
      </table>     
      <table width="100%" border="0" cellpadding="2" cellspacing="0">
        <tr class="header">
          <td><div align="left">&nbsp;$date&nbsp;</div></td>
          <td><div align="right">$myaccount | $cartcontents | $checkout&nbsp;</div></td>
        </tr>
      </table>     
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td class="headerNavigation">$breadcrumbs</td>
        </tr>
      </table>
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td class="lijevo" rowspan="2" valign="top"> <p>$searchbox$categorybox
              <br>
              $currenciesbox$languagebox $cartbox $orderhistorybox $informationbox<br>
              <img src="images/160.gif"> </p>
            </td>
          <td class="sadrzaj" height="216" colspan="2" valign="top"> <br>
            $content</td>
          <td class="desno" rowspan="2" valign="top"> </td>
        </tr>
        <tr>
          <td width="50%" valign="top">&nbsp;</td>
          <td width="50%" valign="top">$maninfobox</td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table width="758"  border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><div align="center">$footer</div></td>
        </tr>
      </table>
<table width="758" border="0" align="center" cellpadding="3" cellspacing="0">
  <tr>
    <td><div align="center">$banner</div></td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>

design wiew
Cat_a_log
Hallo, i've a problem with STS that i can't resolve...
The page that is generated with STS has an error in the header information, i show you the code:

---------------------------------------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Name of My site</title>
<base href="http://www.mysite.com">
<link rel="stylesheet" type="text/css" href="stylesheet.css">

<!-- start get_javascript(applicationtop2header) //-->
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="LTR" lang="it">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Name of My site</title>
<base href="http://www.mysite.com">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
---------------------------------------------------------

You can see that the tags <head>, <title> and <html> are repeated. sad.gif
Where is my error?
Thanks for your help.
DiamondSea
QUOTE (Cat_a_log @ Sep 19 2003, 04:19 AM)
Hallo, i've a problem with STS that i can't resolve...
The page that is generated with STS has an error in the header information, i show you the code:

---------------------------------------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Name of My site</title>
<base href="http://www.mysite.com">
<link rel="stylesheet" type="text/css" href="stylesheet.css">

<!-- start get_javascript(applicationtop2header) //-->
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="LTR" lang="it">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Name of My site</title>
<base href="http://www.mysite.com">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
---------------------------------------------------------

You can see that the tags <head>, <title> and <html> are repeated. sad.gif
Where is my error?
Thanks for your help.

What version of STS are you using?

Upgrade to STS v1.4 and it should fix this problem.

- Brian
DiamondSea
You can also update this function to fix the problem with your current version:

CODE
function get_javascript($tmpstr, $commentlabel) {
 // Now lets remove the <tr><td> that the require puts in front of the tableBox
 $tablestart = strpos($tmpstr, "<script");

 // If empty, return nothing
 if ($tablestart === false) {
       return  "\n<!-- start $commentlabel //-->\n$tmpstr\n<!-- end $commentlabel //-->\n";
 }

 $tmpstr = substr($tmpstr, $tablestart); // strip off stuff before <table>

 // Now lets remove the </td></tr> at the end of the tableBox output
 // strrpos only works for chars, not strings, so we'll cheat and reverse the string and then use strpos
 $tmpstr = strrev($tmpstr);

 $tableend = strpos($tmpstr, strrev("</script>"), 1);
 $tmpstr = substr($tmpstr, $tableend);  // strip off stuff after </table>

 // Now let's un-reverse it
 $tmpstr = strrev($tmpstr);

 // print "<hr>After cleaning tmpstr:" . strlen($tmpstr) . ": FULL=[".  htmlspecialchars($tmpstr) . "]<hr>\n";
 return  "\n<!-- start $commentlabel //-->\n$tmpstr\n<!-- end $commentlabel //-->\n";
}


But it's better to just upgrade.

-Brian
SevenD
QUOTE
You can also update this function to fix the problem with your current version:


Which file need to edit?
DiamondSea
QUOTE (SevenD @ Sep 19 2003, 10:39 AM)
QUOTE
You can also update this function to fix the problem with your current version:


Which file need to edit?

It's in application_bottom.php in v1.2, and in sts_display_output.php in v1.3+
mocara
Anyone out there got a site running this Contrib? It would be nice to see it in action.
j0ker
I have a test site I am playing with using sts1.3, and I am running quite a lot of other contribs including STS on this site.
biggrin.gif
testing
Plz note that the css is all over the place and I hope to sort today, this has nothing to do with the sts.
I also have version 1.4 running on another site under test at Testing another biggrin.gif

If its speeding the construction of your site that interests you, sts is what you need and it works great.
j0ker
DiamondSea
QUOTE (j0ker @ Sep 20 2003, 03:19 AM)
I have a test site I am playing with using sts1.3, and I am running quite a lot of other contribs including STS on this site.
biggrin.gif
testing
Plz note that the css is all over the place and I hope to sort today, this has nothing to do with the sts.
I also have version 1.4 running on another site under test at Testing another biggrin.gif

If its speeding the construction of your site that interests you, sts is what you need and it works great.
j0ker

You can see the templates for the above sites here:

http://www.firstbyte.biz/pink/catalog/includes/template.html

http://firstbyte.biz/catalog/includes/sts_template.html

One trick you can use to make debugging the templates easier is to make your image and stylesheet links absolute URL's (with a leading slash or http://) instead of relative (no leading slash).

This will allow you to simply view the template page in your browser exactly as it will appear on your site, as opposed to the missing-image version you get with relative URL's, above.

Just a tip!

- Brian
j0ker
Thx for the reply,

Nice tip that, I seem to think some ref to that tip in your original docs, but being new to osc and php and keen to get goin I didnt read the docs. sad.gif

I can see a lot in the contrib though as it helps newbies like me to alter osc to look better than the default solution supplied.

Keep up the very good work, I look forward to the next version.

If you need any help testing versions plz dont hesitate to contact me as I am able to bang up a new osc at a moments notice for testing.

Regards
Elwyn
Vaiso
I have just downloaded V1.4 and uploaded the appropriate files and attribed them to 777 just to be sure. I also update the configure.php file as requested.
When I try to load the shop (222.vaiso.com/catalog) I get returned to the OSCommerce installation/upgrade screen. I went through the process of entering my config details again and tried to access the shop.
I get the error shown belo. Can anyone please help :-

Warning: main(STS_START_CAPTURE): failed to open stream: No such file or directory in /home/vaisoco/public_html/catalog/includes/application_top.php on line 511

Fatal error: main(): Failed opening required 'STS_START_CAPTURE' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/vaisoco/public_html/catalog/includes/application_top.php on line 511
j0ker
If this is lioke a new install you must delete the upgrade file or rename it? maybe.

The configure.php did you replace it completely or did you mode it to reflect your shop settings?

More info plz, but if you have replaced the config completely try reverting back to a backup configure file and manually editing the configure.php file with the sts lines of code.. biggrin.gif
Vaiso
The first time I think I edited the original configure.php file with the required code instead of the one on the server.
I have now reinstalled OSCommerce completely and even before running the install process I have copied the STS (V1.4) files over and edited the configure.php file.
When I run the install process all is fine but I receive the error below when trying to access the shop.
I notice there is a configure.php file in catalog/admin/includes as well as catalog/includes. Does the admin version need to have the STS files also?

ERROR MESSAGE RECEIVED
Warning: main(STS_START_CAPTURE): failed to open stream: No such file or directory in /home/vaisoco/public_html/catalog/includes/application_top.php on line 511

Fatal error: main(): Failed opening required 'STS_START_CAPTURE' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/vaisoco/public_html/catalog/includes/application_top.php on line 511
j0ker
Have you uploaded this file which was missing out of the first release of the 1.4 version?

sts_display_output.php

If so you confirm that you have edited the code, in includes/configure.php you do not need to edit any further config files in admin.

Just a little question, do you have a link for me to see the error or are you running your osc local on a pc?



rolleyes.gif
Vaiso
The file sts_display_output.php was present in my V1.4 download and has been uploaded with the other files.
You can view the error at www.vaiso.com/catalog

Just to be sure I have copied the last lines of my configure.php file for you to see.
I am terribly sorry for wasting your time on such a trivial issue.

// define our database connection
define('DB_SERVER', ''); // eg, localhost - should not be empty for productive servers
define('DB_SERVER_USERNAME', '');
define('DB_SERVER_PASSWORD', '');
define('DB_DATABASE', 'osCommerce');
define('USE_PCONNECT', 'false'); // use persistent connections?
define('STORE_SESSIONS', ''); // leave empty '' for default handler or set to 'mysql'
// STS: ADD: Define Simple Template System files
define('STS_START_CAPTURE', DIR_WS_INCLUDES . 'sts_start_capture.php');
define('STS_STOP_CAPTURE', DIR_WS_INCLUDES . 'sts_stop_capture.php');
define('STS_RESTART_CAPTURE', DIR_WS_INCLUDES . 'sts_restart_capture.php');
define('STS_TEMPLATE', DIR_WS_INCLUDES . 'sts_template.html');
define('STS_DISPLAY_OUTPUT', DIR_WS_INCLUDES . 'sts_display_output.php');
// STS: EOADD
?>
DiamondSea
QUOTE (Vaiso @ Sep 21 2003, 01:03 PM)
The file sts_display_output.php was present in my V1.4 download and has been uploaded with the other files.
You can view the error at www.vaiso.com/catalog

Just to be sure I have copied the last lines of my configure.php file for you to see.
I am terribly sorry for wasting your time on such a trivial issue.

// define our database connection
  define('DB_SERVER', ''); // eg, localhost - should not be empty for productive servers
  define('DB_SERVER_USERNAME', '');
  define('DB_SERVER_PASSWORD', '');
  define('DB_DATABASE', 'osCommerce');
  define('USE_PCONNECT', 'false'); // use persistent connections?
  define('STORE_SESSIONS', ''); // leave empty '' for default handler or set to 'mysql'
// STS: ADD: Define Simple Template System files
  define('STS_START_CAPTURE', DIR_WS_INCLUDES . 'sts_start_capture.php');
  define('STS_STOP_CAPTURE', DIR_WS_INCLUDES . 'sts_stop_capture.php');
  define('STS_RESTART_CAPTURE', DIR_WS_INCLUDES . 'sts_restart_capture.php');
  define('STS_TEMPLATE', DIR_WS_INCLUDES . 'sts_template.html');
  define('STS_DISPLAY_OUTPUT', DIR_WS_INCLUDES . 'sts_display_output.php');
// STS: EOADD
?>

I suspect that your problem is that you are installing the STS files before actually configuring the system's database.

In the configure.php file listed below none of your settings are present.

Try this:

1) Remove everything
2) Install a clean copy of osC 2.2MS2
3) Run the install program to establish that your database works. Go and make sure that your osC installation works.
4) THEN, once you know that everything works, copy the STS files in place
5) Copy the last few lines from the configure-SAMPLE.php onto the end of your /catalog/includes/configure.php file:

CODE
// STS: ADD: Define Simple Template System files
 define('STS_START_CAPTURE', DIR_WS_INCLUDES . 'sts_start_capture.php');
 define('STS_STOP_CAPTURE', DIR_WS_INCLUDES . 'sts_stop_capture.php');
 define('STS_RESTART_CAPTURE', DIR_WS_INCLUDES . 'sts_restart_capture.php');
 define('STS_TEMPLATE', DIR_WS_INCLUDES . 'sts_template.html');
 define('STS_DISPLAY_OUTPUT', DIR_WS_INCLUDES . 'sts_display_output.php');
// STS: EOADD


STS should only be installed in the /catalog/includes/, NOT in the /catalog/admin/ directories. STS is not used by the Admin system at all.

Also, whenever I upload a new file it will get a new version number to prevent the confusion that results from having multiple "versions" of the same version.

- Brian

PS: In the spirit of global technical lingo, the phrase "attribed them to 777" is a mixed metaphor. Attrib is a DOS/Windows command. The Unix/Linux command is "chmod" which is short for CHange MODe. The phrase would be "I chmod'ed the files to 777" or "I chmod 777'ed the files" or something like this. Just doin' my part in the Unixification of the world! wink.gif
DiamondSea
Simple Template System (STS) v1.5 Released

Okay, I've put up a new version of STS that provides even more functionality than previous versions.

Major Change: Added $urlcat_xxxx variables to let you link directly to a category by Name or by numeric cPath (as seen in the URL). This lets you easily create links to category pages by text or images or imagemaps for a menu. Use a link like $urlcat_Mice or urlcat_1_9 to link directly to a particular category.

Created a sts_user_code.php so you can add new boxes and other template variables without having to mess with the other files. You will need to add the STS_USER_CODE definition to your configure.php file (see README.txt).

Added the name of the template file to the debugging output to make troubleshooting easier.

Added new TIPS section to README.txt file for ways to help make debugging templates even easier.

The errors and warnings now show in the $content section of the template. It was not displayed in previous versions which could lead to configuration problems.

A few other changes to the README.txt file to help with installation.

That's pretty much it. Hopefully I didn't mess anything up with my 1:30AM build! smile.gif

Enjoy!

- Brian
Vaiso
Thanks for the advice.
I have done exactly as you suggested but still receive the same error.If I copy back the old configure.php file everything works fine.
Is there any way that someone could take a look at my code as I am going mad here.
DiamondSea
QUOTE (Vaiso @ Sep 22 2003, 02:55 PM)
Thanks for the advice.
I have done exactly as you suggested but still receive the same error.If I copy back the old configure.php file everything works fine.
Is there any way that someone could take a look at my code as I am going mad here.

You need to copy these lines to the end of your working configure.php file:

CODE
// STS: ADD: Define Simple Template System files
 define('STS_START_CAPTURE', DIR_WS_INCLUDES . 'sts_start_capture.php');
 define('STS_STOP_CAPTURE', DIR_WS_INCLUDES . 'sts_stop_capture.php');
 define('STS_RESTART_CAPTURE', DIR_WS_INCLUDES . 'sts_restart_capture.php');
 define('STS_TEMPLATE', DIR_WS_INCLUDES . 'sts_template.html');
 define('STS_DISPLAY_OUTPUT', DIR_WS_INCLUDES . 'sts_display_output.php');
 define('STS_USER_CODE', DIR_WS_INCLUDES . 'sts_user_code.php');
// STS: EOADD


(the STS_USER_CODE is new to v1.5, but won't hurt if you have an earlier version).

It sounds like you are losing your settings for your database connections when you replace your working configure.php file with the configure-SAMPLE.php one. You aren't supposed to copy the configure-SAMPLE.php file over top of the configure.php file, because you clobber your database settings that you have defined in these lines (in configure.php):

CODE
// define our database connection
 define('DB_SERVER', 'localhost'); // eg, localhost - should not be empty for productive servers
 define('DB_SERVER_USERNAME', 'yourdbusername');
 define('DB_SERVER_PASSWORD', 'yourdbpassword');
 define('DB_DATABASE', 'yourdatabasename');
 define('USE_PCONNECT', 'false'); // use persistent connections?
 define('STORE_SESSIONS', 'mysql'); // leave empty '' for default handler or set to 'mysql'


(The yourdbusername and other values should actually contain the settings that are appropriate for your server.)

Hope this helps!

- Brian
Vaiso
Thanks for your help.
I checked the configure file and the database details were indeed missing.

One quick point - I am awful with coding but do want to control the design layout hence the reason for using your contribution.
Am I correct in thinking that any alteraion to the template file will be seen in all OSCommerce pages?
My sincere thanks for your help.
bottlerocket
Hrm. I seem to be having a problem with the STS_USER_CODE. I believe I have it configured correctly in the file:

CODE
  $sts_block_name = 'articlebox';
  require(STS_START_CAPTURE);
  require(DIR_WS_BOXES . 'articlecat.php');
  require(STS_STOP_CAPTURE);


But in the template, it just displays the variable name as &articlebox. You can see this at http://dev.golfcarcatalog.com/catalog/index.php.

Any ideas?
devosc
Hi Brian,

Thanks for the contribution.

I downloaded the STS-1_5 zip file and read the readme file which seemed ok but what I couldn't see was how the html_template actually begins to interact with php and oscommerce. For example in the default index.php file one is required to include the application_top and bottom files.

Would it be possible to see how from creating the template, in which I assume one expects to see the $declaration - knowing that that in php the correct reference is displayed, it is then actually implemented as a php file via a sample php file?

Thanks,

Greg.
DiamondSea
QUOTE (Vaiso @ Sep 22 2003, 04:37 PM)
Thanks for your help.
I checked the configure file and the database details were indeed missing.

One quick point - I am awful with coding but do want to control the design layout hence the reason for using your contribution.
Am I correct in thinking that any alteraion to the template file will be seen in all OSCommerce pages?
My sincere thanks for your help.

You are correct. The changes will be applied to all /catalog/ pages, except pop-up windows. Admin pages will not be affected.

- Brian
DiamondSea
QUOTE (bottlerocket @ Sep 22 2003, 04:46 PM)
Hrm. I seem to be having a problem with the STS_USER_CODE. I believe I have it configured correctly in the file:

CODE
  $sts_block_name = 'articlebox';
  require(STS_START_CAPTURE);
  require(DIR_WS_BOXES . 'articlecat.php');
  require(STS_STOP_CAPTURE);


But in the template, it just displays the variable name as &articlebox. You can see this at  http://dev.golfcarcatalog.com/catalog/index.php.

Any ideas?

My apologies, I ommitted a the code that adds it to the template. The sts_user_code.php commented out code should have read like this:

CODE
 // $sts_block_name = 'newthingbox';
 // require(STS_START_CAPTURE);
 // require(DIR_WS_BOXES . 'new_thing_box.php');
 // require(STS_STOP_CAPTURE);
 // $template['newthingbox'] = strip_unwanted_tags($sts_block['newthingbox'], 'newthingbox');


Copy the lines and uncomment them to do whatever you want.

Change your file to read like this (I just added the last line):

CODE
  $sts_block_name = 'articlebox';
  require(STS_START_CAPTURE);
  require(DIR_WS_BOXES . 'articlecat.php');
  require(STS_STOP_CAPTURE);
  $template['articlebox'] = strip_unwanted_tags($sts_block['articlebox'], 'articlebox');


Hope this helps!

- Brian
DiamondSea
QUOTE (gregbaboolal @ Sep 22 2003, 06:00 PM)
Hi Brian,

Thanks for the contribution.

I downloaded the STS-1_5 zip file and read the readme file which seemed ok but what I couldn't see was how the html_template actually begins to interact with php and oscommerce. For example in the default index.php file one is required to include the application_top and bottom files.

Would it be possible to see how from creating the template, in which I assume one expects to see the $declaration - knowing that that in php the correct reference is displayed, it is then actually implemented as a php file via a sample php file?

Thanks,

Greg.


Here's how it works. In application_top.html it calls the STS_START_CAPTURE script, which calls the PHP function ob_start() which captures the output buffer and saves it to a string in $sts_block[$stringname] defined before it calls STS_STOP_CAPTURE.

It does the same process for each of the files replaced by this contribution. In the column_left.php function, there is a separate set of capture and save commands around each of the BOX-creation functions.

When it's all done, application_bottom.php calls sts_display_output.php which goes through the saved variables and removes some of the formatting code (starting and ending <td> and <tr> tags) that is used by OSC but isn't wanted by the template system.

It then reads the STS_TEMPLATE file into a single string variable in memory.

Then it sorts all the $template[$variablename] variables by the string-length of the $variablename, from largest to smallest. It then replaces any occurance of $variablename in the saved STS_TEMPLATE string with the values stored in the the corresponding $template[$variablename] string.

Then it prints out the saved & find-and-replaced STS_TEMPLATE string to the browser.

Does this answer your question?

- Brian
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.