Jump to content
Latest News: (loading..)
DiamondSea

[contribution] Simple Template System (sts)

Recommended Posts

This is one example of sts_template.html (without right column). prewiew

Change the style.css for custom look.

 

<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"> $date </div></td>

          <td><div align="right">$myaccount | $cartcontents | $checkout </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"> </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> </p>

</body>

</html>

design wiew


_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/

(\__/)

(O.o )

(> < )

Share this post


Link to post
Share on other sites

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. :(

Where is my error?

Thanks for your help.

Share this post


Link to post
Share on other sites
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. :(

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


Simple Template System (STS)

Layout your site with 1 (or more) HTML file!

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

Support: http://forums.oscommerce.com/index.php?showtopic=58541

Share this post


Link to post
Share on other sites

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

 

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


Simple Template System (STS)

Layout your site with 1 (or more) HTML file!

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

Support: http://forums.oscommerce.com/index.php?showtopic=58541

Share this post


Link to post
Share on other sites
You can also update this function to fix the problem with your current version:

 

Which file need to edit?


_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/

(\__/)

(O.o )

(> < )

Share this post


Link to post
Share on other sites
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+


Simple Template System (STS)

Layout your site with 1 (or more) HTML file!

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

Support: http://forums.oscommerce.com/index.php?showtopic=58541

Share this post


Link to post
Share on other sites

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.

:D

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 :D

 

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

j0ker


Always seeking & Desperate to find a solution!

Share this post


Link to post
Share on other sites
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.

:D

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 :D

 

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


Simple Template System (STS)

Layout your site with 1 (or more) HTML file!

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

Support: http://forums.oscommerce.com/index.php?showtopic=58541

Share this post


Link to post
Share on other sites

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. :(

 

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


Always seeking & Desperate to find a solution!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.. :D


Always seeking & Desperate to find a solution!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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:


Always seeking & Desperate to find a solution!

Share this post


Link to post
Share on other sites

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

?>

Share this post


Link to post
Share on other sites
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:

 

// 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! ;)


Simple Template System (STS)

Layout your site with 1 (or more) HTML file!

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

Support: http://forums.oscommerce.com/index.php?showtopic=58541

Share this post


Link to post
Share on other sites

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! :)

 

Enjoy!

 

- Brian


Simple Template System (STS)

Layout your site with 1 (or more) HTML file!

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

Support: http://forums.oscommerce.com/index.php?showtopic=58541

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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:

 

// 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):

 

// 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


Simple Template System (STS)

Layout your site with 1 (or more) HTML file!

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

Support: http://forums.oscommerce.com/index.php?showtopic=58541

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Hrm. I seem to be having a problem with the STS_USER_CODE. I believe I have it configured correctly in the file:

 

   $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?

Share this post


Link to post
Share on other sites

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.


"Any fool can know. The point is to understand." -- Albert Einstein

Share this post


Link to post
Share on other sites
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


Simple Template System (STS)

Layout your site with 1 (or more) HTML file!

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

Support: http://forums.oscommerce.com/index.php?showtopic=58541

Share this post


Link to post
Share on other sites
Hrm. I seem to be having a problem with the STS_USER_CODE. I believe I have it configured correctly in the file:

 

   $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:

 

  // $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):

 

   $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


Simple Template System (STS)

Layout your site with 1 (or more) HTML file!

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

Support: http://forums.oscommerce.com/index.php?showtopic=58541

Share this post


Link to post
Share on other sites
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

Edited by DiamondSea

Simple Template System (STS)

Layout your site with 1 (or more) HTML file!

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

Support: http://forums.oscommerce.com/index.php?showtopic=58541

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×