Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] STS v4


Guest

Recommended Posts

Call stack comes from the debugger I have installed, it doesn't come up with default PHP installation. referencing line 52 just points to the closing tag of the same function as the line 33, maybe it's PHP version that causes the errors to be different. However I just noticed that the error comes from incorrect upgrade.

If you upgrade your STS Plus 4.07 to STS 4.1, remember to modify application_bottom.php and remove the following lines from there (as these are now handled in footer.php):

 

$sts->stop_capture('footer2applicationbottom');

require (DIR_WS_MODULES . 'sts_inc/sts_display_output.php'); // Print everything out

Thanks teniemi - i confirmed this as well having to go back through the install process again and the same error popping up. Is there any official reference to the fix you mentioned above? I didn't see it the 4.07 to 4.1 update section of the 4.1 install.html, and all we were told to do is replace application_bottom yet no application_bottom file was provided. i guess we were supposed to get that file from the base OSC install package. Perhaps Bill or Rigadin can update 4.1 install in the contrib section so other 4.07 upgraders don't have this same problem.

 

cheers

Link to comment
Share on other sites

Regarding STS and HTC....

 

For the page title of my catalog home page (index.php_0.html) all i get is "- osCommerce :". For my category product listings I get the category name followed by osCommerce ex. "Vertical Streamers - osCommerce :" For my individual products I get the correct page title ex. "Nirvana Streamer"

 

Can anyone help please? My understanding is that STS will insert the header content of the template and override HTC. It is not pulling header info (<!--$headcontent-->) from my templates at all - Am i missing an obvious step or piece of knowledge?

 

Thxs

Link to comment
Share on other sites

Hi,

 

I've not had any feedback on my query a couple of days ago, and can't find similar problems with the STS install in this forum, can anyone help me with the actual installation of STS 4? This was my original comment:

 

 

I'm fairly new to osCommerce so jumped at the change to make editing of templates easier. I've downloaded STS 4.1 as well as the updates (dated 12th and 14th April) and uploaded these new files to my site, but though I'm getting the STS menu option in my admin/modules, it shows the same list as for 'Payment Modules'. That is, I'm not seeing any opportunity to actually enable 'default' and get started.

 

Am I missing something obvious?! Thanks so much

 

Mike

Link to comment
Share on other sites

Hi,

 

I've not had any feedback on my query a couple of days ago, and can't find similar problems with the STS install in this forum, can anyone help me with the actual installation of STS 4? This was my original comment:

 

 

I'm fairly new to osCommerce so jumped at the change to make editing of templates easier. I've downloaded STS 4.1 as well as the updates (dated 12th and 14th April) and uploaded these new files to my site, but though I'm getting the STS menu option in my admin/modules, it shows the same list as for 'Payment Modules'. That is, I'm not seeing any opportunity to actually enable 'default' and get started.

 

Am I missing something obvious?! Thanks so much

 

Mike

Mike, I know you probably already did this but it would benefit you to do it again. Go over your entire installation of STS 4.1 very slowly. Confirm that you actually copied all of the files and folders over to your web server keeping the folder structure of the contribution intact. It appears that you did not transfer all of the STS files or folders over to your shops directory. Double check everything.

 

By the way, what version of osCommerce are you using? Is it Cre-loaded or just the standard osCommerce? Have you installed any other contributions to osCommerce? Please provide more info.

 

Thanks, Bill Kellum

Bill Kellum

 

Sounds Good Productions

STS Tutorials & more: STSv4.6, STS Add-ons (STS Power Pack), STS V4 Forum STS Forum FREE TEMPLATE

Link to comment
Share on other sites

Mike, I know you probably already did this but it would benefit you to do it again. Go over your entire installation of STS 4.1 very slowly. Confirm that you actually copied all of the files and folders over to your web server keeping the folder structure of the contribution intact. It appears that you did not transfer all of the STS files or folders over to your shops directory. Double check everything.

 

By the way, what version of osCommerce are you using? Is it Cre-loaded or just the standard osCommerce? Have you installed any other contributions to osCommerce? Please provide more info.

 

Thanks, Bill Kellum

 

Thanks very much Bill - I installed osCommerce 2.2ms2-051113, and also have Easy Populate EP_v2_76_MS2. I only downloaded STS 4.1, added the clean_osc folder and the 4.1 update (though I don't think I did anything with the 'upload' folder. Otherwise I think all the required files have been added. While the STS directory shows up in the admin area of the website, its contents are the same as the Payment section.

 

Thanks again

 

Mike

Link to comment
Share on other sites

Thanks very much Bill - I installed osCommerce 2.2ms2-051113, and also have Easy Populate EP_v2_76_MS2. I only downloaded STS 4.1, added the clean_osc folder and the 4.1 update (though I don't think I did anything with the 'upload' folder. Otherwise I think all the required files have been added. While the STS directory shows up in the admin area of the website, its contents are the same as the Payment section.

 

Thanks again

 

Mike

Mike, I feel your problems arise from an incorrect installation of STS. Here is what you needed to do:

 

1. Follow the instructions in the install text in section 3b.

 

2. You will need to manually edit each file listed in the Admin and Catalog sections of the install text.

 

3. Follow the instructions in the install text in the "Configuration" section. For a simple template system, all you need to do is enable the new "Default" module that is located in the Admin/Modules/BOX_MODUELES_STS section of your stores admin panel.

 

You should now be able to get things going. By making the manual edits to each page, your other contributions, in your case Easy Populate, should work with no issues (that is if they were working before your STS installation of course).

 

Hope this helps,

 

Bill Kellum

Bill Kellum

 

Sounds Good Productions

STS Tutorials & more: STSv4.6, STS Add-ons (STS Power Pack), STS V4 Forum STS Forum FREE TEMPLATE

Link to comment
Share on other sites

Regarding STS and HTC....

 

 

 

Can anyone help please? My understanding is that STS will insert the header content of the template and override HTC. It is not pulling header info (<!--$headcontent-->) from my templates at all - Am i missing an obvious step or piece of knowledge?

 

Thxs

Currently, I do not use the "Header Tag" contribution but I do know that it's sole purpose is to replace the metatags of your store's pages. Soooooooooo, I would dive into that contributions help files to see how it does that.

 

With that said, those that use STS to design their pages need to make a choice...do I manually enter the tag info into each page or do I use a contribution such as Header Tag Controller to do it for me? I do not think you can do both and it appears this is what you are trying to do. Am I correct in thinking this or am I the one missing something here? :blink:

 

Trying to be helpful,

 

Bill Kellum

Edited by bkellum

Bill Kellum

 

Sounds Good Productions

STS Tutorials & more: STSv4.6, STS Add-ons (STS Power Pack), STS V4 Forum STS Forum FREE TEMPLATE

Link to comment
Share on other sites

Hi,

 

I have installed the new 4.1 version with all the updates and the typo update, I have re-checked everything, but still get a blank page when I enable the sts.

 

I have tried the test & full templates but still get a blank page. when I disable the sts everything is fine.

 

Have I missed something ?

 

This is my sts.php file:

 

 

require (DIR_WS_FUNCTIONS.'sts.php');

 

class sts {

var $sts_block,

$template,

$display_template_output, $display_debugging_output,

$template_file, $template_folder;

 

function sts (){

$this->update_from_url(); // Check for debug mode from URL

// Use template output if enabled or in debug mode (=only for admin)

if ((MODULE_STS_DEFAULT_STATUS == 'true') || ($this->display_debug_output == true)) {

$this->display_template_output = true;

} else {

$this->display_template_output = false;

return;

}

 

define('STS_TEMPLATE_DIR', DIR_WS_INCLUDES . 'sts_templates/' . $this->template_folder .'/');

define('STS_DEFAULT_TEMPLATE', STS_TEMPLATE_DIR . MODULE_STS_TEMPLATE_FILE);

define('DIR_WS_TEMPLATE_IMAGES', STS_TEMPLATE_DIR . DIR_WS_IMAGES);

 

// Initialisation of variables

$this->template = array('debug' => '',

'headcontent' =>'',

'extracss' =>'');

$this->version= "4.1";

$this->osc_version_required = "osCommerce 2.2-MS2";

 

// Actions to do first

$this->check_version(PROJECT_VERSION); // Check if this STS is running under the correct osCommerce version

 

// Find the right template to use according to actual page and parameters. Displays normal output if no template returned

if ( !tep_not_null($this->find_template()) ) {

$this->display_template_output = false; // If no template returned, do not use templates at all and exit

return;

}

 

if ($this->read_template_file() == false) {

$this->display_template_output = false; // If template file does not exist, do not use templates at all and exit

return;

}

 

} //end constructor

 

function check_version ($osc_version) {

// Perform OSC version checking

if ($osc_version != $this->osc_version_required) {

die("STS4 was designed to work with OSC version [" . $this->osc_version_required . "]. This is version [" . $osc_version . " ]");

}

}

 

function update_from_url () {

global $HTTP_GET_VARS, $sts_template_folder; //, $current_category_id;

 

// Allow Debugging control from the URL

if ($HTTP_GET_VARS['sts_debug'] == MODULE_STS_DEBUG_CODE ) {

$this->display_debug_output = true;

}

 

/*

$sts_template_id = $current_category_id; // *g*

*/

if (tep_not_null($HTTP_GET_VARS['sts_template'])) {

$sts_template_folder = tep_db_prepare_input($HTTP_GET_VARS['sts_template']);

}

 

$template_folder_installed = explode (';', MODULE_STS_TEMPLATE_FOLDER);

 

if ( !isset( $template_folder_installed[(int)$sts_template_folder] ) ) { // default

$sts_template_folder = 0;

$this->template_folder = $template_folder_installed[$sts_template_folder];

} else {

$this->template_folder = $template_folder_installed[(int)$sts_template_folder];

}

 

if (!tep_session_is_registered('sts_template_folder')) {

tep_session_register('sts_template_folder');

}

}

 

function find_template (){

global $PHP_SELF;

// Retrieve script name without path nor parameters

$scriptbasename = basename ($PHP_SELF);

 

// If script name contains "popup" then turn off templates and display the normal output

// This is required to prevent display of standard page elements (header, footer, etc) from the template and allow javascript code to run properly

// Do not add pages here unless it is from the standard osC and really should be there. If you have a special page that you don't want with template,

// Create a module sts_mypagename.php that returns an empty string as template filename, it will automatically switch off STS for this page.

if (strstr($scriptbasename, "popup")|| strstr($scriptbasename, "info_shopping_cart")) {

$this->display_template_output = false;

return;

}

 

// Check for module that will handle the template (for example module sts_index takes care of index.php templates)

$check_file = 'sts_' . $scriptbasename;

$modules_installed = explode (';', MODULE_STS_INSTALLED);

if (!in_array($check_file, $modules_installed))

$check_file = 'sts_default.php';

 

include_once (DIR_WS_MODULES.'sts/' . $check_file);

$classname=substr($check_file,0,strlen($check_file)-4);

$this->script=new $classname; // Create an object from the module

 

// If module existes but is disabled, use the default module.

if ($this->script->enabled==false) {

unset ($this->script);

include_once (DIR_WS_MODULES.'sts/sts_default.php');

$this->script = new sts_default; // Create an object from the module

}

 

$this->template_file = $this->script->find_template(); // Retrieve the template to use

return $this->template_file;

}

 

function start_capture () {

// Start redirecting output to the output buffer, if template mode on.

if ($this->display_template_output) {

ob_start();

}

}

 

function stop_capture ($block_name='', $action='') {

// Store captured output to $sts_capture

if (!$this->display_template_output) return; // Do not process anything if we are not in using templates

$block = ob_get_clean(); // Get content and clean the buffer

if (!tep_not_null($block_name)) return; // Not need to continue if we don't want to save the buffer

 

switch($action) {

case 'box':

$this->template[$block_name]= sts_strip_unwanted_tags($block, $block_name);

break;

default:

$this->template[$block_name] = $block;

} // switch

}

 

function restart_capture ($block_name='sts_empty', $action='') {

// Capture buffer, save it and start a new capture

if (!$this->display_template_output) return;

$this->stop_capture($block_name, $action);

$this->start_capture();

}

 

function capture_fields (){

// If we use template, ask to module what file(s) to include for building fields

if ($this->display_template_output) {

$fields_arr= explode(';', 'general.php;'.$this->script->capture_fields ());

}

return $fields_arr;

}

 

function read_template_file (){

// Purpose: Open Template file and read it

// Generate an error if the template file does not exist and return 'false'.

if (!file_exists($this->template_file)) {

print 'Template file does not exist: ['.$this->template_file.']';

return false;

}

// We use templates and the template file exists

// Capture the template, this way we can use php code inside templates

$this->start_capture(); // Start capture to buffer

require_once($this->template_file); // Includes the template, this way php code can be used in templates*/

$this->stop_capture('template_html');

return true;

} // End read_template_file

 

function replace (){

global $messageStack, $request_type;

 

if (!$this->display_template_output) return; // Go out if we don't use template

if (defined("STS_END_CHAR") == false) define ('STS_END_CHAR', ''); // An end char must be defined, even if empty.

 

// Load up the <head> content that we need to link up everything correctly. Append to anything that may have been set in sts_user_code.php

// Note that since v3.0, stylesheet is not defined here but in the template file, allowing different stylesheet for different template.

$this->template['headcontent'] = $this->template['headcontent'].'';

$this->template['headcontent'] = $this->template['headcontent'].'<meta http-equiv="Content-Type" content="text/html; charset=' . CHARSET . '">' . "\n";

$this->template['headcontent'] = $this->template['headcontent'].$this->template['headertags'];

$this->template['headcontent'] = $this->template['headcontent'].'<base href="' . (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG . '">' . "\n";

$this->template['headcontent'] = $this->template['headcontent'].get_javascript($this->template['applicationtop2header'],'get_javascript(applicationtop2header)');

 

$this->script->replace($this->template); // Module can make tricks here, just before replacing, like using own content template

// Add messages before the content

if ($messageStack->size('header') > 0) {

$this->template['content'] = $messageStack->output('header') . $this->template['content'];

}

 

// Manually replace the <!--$headcontent--> if present

$this->template['template_html'] = str_replace('<!--$headcontent-->', $this->template['headcontent'], $this->template['template_html']);

// Manually replace the <!--$extracss--> with template['extracss']

$this->template['template_html'] = str_replace('<!--$extracss-->', $this->template['extracss'], $this->template['template_html']);

 

// Automatically replace all the other template variables

if (STS_END_CHAR=='') { // If no end char defined for the placeholders, have to sort the placeholders.

uksort($this->template, "sortbykeylength"); // Sort array by string length, so that longer strings are replaced first

}

 

foreach ($this->template as $key=>$value) {

$this->template['template_html'] = str_replace('$' . $key . STS_END_CHAR , $value, $this->template['template_html']);

}

}

 

// *****************************************

// Functions added for debug

// *****************************************

function add_debug ($text, $br=true) {

// STS v4.1: Add debug text to the STS PLUS debug variable. If $br=false, then no line break added

$this->template['debug'].= $text . ($br ? "\n" : '');

}

 

} //end class

?>

 

 

End of file____________________________________________________________________________

_

 

 

When using the STS which page does it go to first ? If I know this I may beable to find out the problem.

 

Thank in advance.

 

Iain

Link to comment
Share on other sites

aloha Bill,

 

I did that and it still does the same. Allow me to be a bit more specific.

 

For the page title of my catalog home page (index.php_0.html) all i get is "- osCommerce :". For my category product listings I get the category name followed by osCommerce ex. "Vertical Streamers - osCommerce :" For my individual products I get the correct page title ex. "Nirvana Streamer"

 

I am using product info/content templates specific to each category, a template for the catalog home page and the default template for everything else - including category product listings and my secondary pages, such as shipping.php, which also only get "- osCommerce :").

 

Any ideas? - thanks for all your help, it really has made a difference over here! :D

Take a look at the following posts in the HTC forum just to be sure you have HTC setup correctly:

 

Posts 2088 & 2089

 

Hope this helped,

 

Bill Kellum

Bill Kellum

 

Sounds Good Productions

STS Tutorials & more: STSv4.6, STS Add-ons (STS Power Pack), STS V4 Forum STS Forum FREE TEMPLATE

Link to comment
Share on other sites

When using the STS which page does it go to first ? If I know this I may beable to find out the problem.

 

Thank in advance.

 

Iain

Iain, when you log into your osCommerce admin panel, click on Modules, do you see the BOX_MODULES_STS module? If so, have you enabled the Default module?

 

If the Default module is enabled, check to see that the following is correct:

 

Use Templates?

true

 

Code for debug output

debug

 

Files for normal template

sts_user_code.php

 

Template folder

test

 

Default template file

sts_template.html

 

As you can see above, the file you are looking for would be "sts_template.html". This is the file that is used by default. Of course, STS v4.1 is more powerful than a one template for all pages solution but I advise you to at least get to first base before going for the grandslam.

 

Hope this helps,

 

Bill Kellum

Bill Kellum

 

Sounds Good Productions

STS Tutorials & more: STSv4.6, STS Add-ons (STS Power Pack), STS V4 Forum STS Forum FREE TEMPLATE

Link to comment
Share on other sites

Mike, I feel your problems arise from an incorrect installation of STS. Here is what you needed to do:

 

1. Follow the instructions in the install text in section 3b.

 

2. You will need to manually edit each file listed in the Admin and Catalog sections of the install text.

 

3. Follow the instructions in the install text in the "Configuration" section. For a simple template system, all you need to do is enable the new "Default" module that is located in the Admin/Modules/BOX_MODUELES_STS section of your stores admin panel.

 

You should now be able to get things going. By making the manual edits to each page, your other contributions, in your case Easy Populate, should work with no issues (that is if they were working before your STS installation of course).

 

Hope this helps,

 

Bill Kellum

 

Thanks so much Bill - will try this next!

 

Mike

Link to comment
Share on other sites

Take a look at the following posts in the HTC forum just to be sure you have HTC setup correctly:

 

Posts 2088 & 2089

 

Hope this helped,

 

Bill Kellum

 

Boy I appreciate you sticking with me on this one. None of the functions in the HTC Text Control work for the pages (they are all red) because we were told not to do the catalog php file modifications to HTC if we have STS. If I do those modifications for index.php, for example, it works and draws the header info from templates (index_0, etc)- go figure?

 

The problem now that it is not bringing in the fields that HTC populated for the products so that I can't have a page title that matches my product name. Even if I go back to an unmodified index.php. The wierd thing is that right after I installed HTC (and all the pages were red). I populated the HTC product fields and it was successfully generating the product page titles. Now I can't get it to behave that way again.

 

Is there a file I can delete or restore that would give me the initial settings for HTC? Any other ideas for this in general?

 

PS: I am using product info and content templates

 

thxs

Link to comment
Share on other sites

For some strange reason I also get 2 headers on my page (http://www.retroshop.nl). If you look in the source you will see that it put some code before the <head>.

This is after a upgrade from 4.07

Frisser, you did not add the following:

 

Open catalog/includes/header.php

add this code at the beginning:

[font=monospace]  // START [/font][font=monospace]STS 4.1[/font][font=monospace]
 $sts->restart_capture ('applicationtop2header');
 // END [/font][font=monospace]STS 4.1[/font]

and be sure to remove the old sts 4.07 start capture code at the bottom of the same page.

 

Hope this helps,

 

Bill Kellum

Bill Kellum

 

Sounds Good Productions

STS Tutorials & more: STSv4.6, STS Add-ons (STS Power Pack), STS V4 Forum STS Forum FREE TEMPLATE

Link to comment
Share on other sites

How do i upgrade form version 2.0 to 4.1?
The easiest way would be to completely uninstall v2 and follow the install instructions for a new installation of 4.1.

 

However; you can always follow these instructions as well:

 

- Make a backup of your application, files and db.

- Do it again.

- Remove STS v2 or v3, but keep the files near, especially sts_user_code.php. Files to modify: configure.php, header.php, column_left.php, column_right.php, footer.php .

- Install STS v4.1

- Put back your specialities in the new sts_user_code.php, using the new syntax (see example in the file itself).

- Test well.

 

Hope this helps,

 

Bill Kellum

Bill Kellum

 

Sounds Good Productions

STS Tutorials & more: STSv4.6, STS Add-ons (STS Power Pack), STS V4 Forum STS Forum FREE TEMPLATE

Link to comment
Share on other sites

To remove STS v2 or v3 from your store, you also have to remove STS code from application_top.php (end of the file) and from application_bottom (beginning of the file). The files starting by sts_ in the includes folder can be deleted (or copied somewhere else, just in case something goes wrong).

 

Be sure that you remove sts code from the configure.php file, otherwise you will not be able to choose the template folder from URL nor from STS4 default module in admin.

 

- Rigadin

Link to comment
Share on other sites

To upgrade from STS PLUS to STS4, instructions tell to replace the file application_bottom.php with a new one... which is not provided in the package. Well, in fact STS4 does not require any modification in this file, so what you have to do is to remove from application_bottom.php the code related to STS PLUS.

 

- Rigadin

Link to comment
Share on other sites

Frisser, you did not add the following:

 

Open catalog/includes/header.php

add this code at the beginning:

[font=monospace]  // START [/font][font=monospace]STS 4.1[/font][font=monospace]
 $sts->restart_capture ('applicationtop2header');
 // END [/font][font=monospace]STS 4.1[/font]

and be sure to remove the old sts 4.07 start capture code at the bottom of the same page.

 

Hope this helps,

 

Bill Kellum

 

wrong sts.php version was causing the double headers in my case

Edited by bdanen
Link to comment
Share on other sites

Hi,

 

I recently installed osCommerce, everything worked fine (images, links, etc.) so I installed STS 4.1 a couple days ago. I got the index.php.html page updated so I basically just copied it for the product_info.php.html page. The second page however doesn't show any images even though when I look at the code, it appears to be correct. Can someone look at my page and see if you can see something I'm missing? http://www.westvillagedesign.com

 

Also, I guess I am not understanding how to create templates for all of the "extra" pages in osC. By that I mean the cart, user account pages, check out and every page other than products and index.php. I'm missing that part because I see a lot pages with code but they don't seem like something I should be editing :huh: If someone could point me in the right direction I'd really appreciate it.

 

Thanks,

Diana

Link to comment
Share on other sites

Iain, when you log into your osCommerce admin panel, click on Modules, do you see the BOX_MODULES_STS module? If so, have you enabled the Default module?

 

If the Default module is enabled, check to see that the following is correct:

 

Use Templates?

true

 

Code for debug output

debug

 

Files for normal template

sts_user_code.php

 

Template folder

test

 

Default template file

sts_template.html

 

As you can see above, the file you are looking for would be "sts_template.html". This is the file that is used by default. Of course, STS v4.1 is more powerful than a one template for all pages solution but I advise you to at least get to first base before going for the grandslam.

 

Hope this helps,

 

Bill Kellum

 

 

 

 

 

 

Bill,

 

Yes all is set as above and default is enabled. The other two templates index and product info are not installed is this correct ?

 

Other than that I have tried installing it all again and still get the same problem.

 

When I try to go to use the STS the page actually loads, ie it gives the page heading a title

 

http://englishbooksdirect.com/catalog/index.php

 

So it may be a problem with the inital code I am not sure.

Link to comment
Share on other sites

I have inserted the scrips into the admin and category files, but when I open the site i get this:

 

// START STS 4.1 require (DIR_WS_CLASSES.'sts.php'); $sts= new sts(); $sts->start_capture(); // END STS 4.1

Fatal error: Call to a member function on a non-object in /var/www/virtual/unitshop.no/htdocs/shop/includes/header.php on line 3

 

What have I done wrong here?

Link to comment
Share on other sites

Ian, use the following as your includes/classes/sts.php:

 

  [size="2"]

<?php

/*

$Id: sts.php,v 4.1 2006/03/06 22:30:54 Rigadin Exp $

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

Copyright (c) 2005 osCommerce

Released under the GNU General Public License

* 

* STS v4.1

*/

require (DIR_WS_FUNCTIONS.'sts.php');

class sts {

var $sts_block,

$template,

$display_template_output, $display_debugging_output,

$template_file, $template_folder;



function sts (){

$this->update_from_url(); // Check for debug mode from URL

// Use template output if enabled or in debug mode (=only for admin)

if ((MODULE_STS_DEFAULT_STATUS == 'true') || ($this->display_debug_output == true)) {

$this->display_template_output = true;

} else { 

$this->display_template_output = false;

return;

}

define('STS_TEMPLATE_DIR', DIR_WS_INCLUDES . 'sts_templates/' . $this->template_folder .'/');

define('STS_DEFAULT_TEMPLATE', STS_TEMPLATE_DIR . MODULE_STS_TEMPLATE_FILE);

define('DIR_WS_TEMPLATE_IMAGES', STS_TEMPLATE_DIR . DIR_WS_IMAGES);

// Initialisation of variables

$this->template = array('debug' => '', 

'headcontent' =>'',

'extracss' =>'');

$this->version= "4.1";

$this->osc_version_required = "osCommerce 2.2-MS2";

// Actions to do first

$this->check_version(PROJECT_VERSION); // Check if this STS is running under the correct osCommerce version

// Find the right template to use according to actual page and parameters. Displays normal output if no template returned

if ( !tep_not_null($this->find_template()) ) {

$this->display_template_output = false; // If no template returned, do not use templates at all and exit

return;

}

if ($this->read_template_file() == false) {

$this->display_template_output = false; // If template file does not exist, do not use templates at all and exit

return;

}

} //end constructor



function check_version ($osc_version) {

// Perform OSC version checking

if ($osc_version != $this->osc_version_required) {

die("STS4 was designed to work with OSC version [" . $this->osc_version_required . "]. This is version [" . $osc_version . " ]");

} 

}



function update_from_url () {

global $HTTP_GET_VARS, $sts_template_folder; //, $current_category_id;

// Allow Debugging control from the URL

if ($HTTP_GET_VARS['sts_debug'] == MODULE_STS_DEBUG_CODE ) {

$this->display_debug_output = true;

}



/*

$sts_template_id = $current_category_id; // *g*

*/

if (tep_not_null($HTTP_GET_VARS['sts_template'])) {

$sts_template_folder = tep_db_prepare_input($HTTP_GET_VARS['sts_template']);

}



$template_folder_installed = explode (';', MODULE_STS_TEMPLATE_FOLDER);



if ( !isset( $template_folder_installed[(int)$sts_template_folder] ) ) { // default

$sts_template_folder = 0;

$this->template_folder = $sts_template_folder[0];

} else {

$this->template_folder = $template_folder_installed[(int)$sts_template_folder];

}

if (!tep_session_is_registered('sts_template_folder')) {

tep_session_register('sts_template_folder');

}

}

function find_template (){

global $PHP_SELF;

// Retrieve script name without path nor parameters

$scriptbasename = basename ($PHP_SELF);

// If script name contains "popup" then turn off templates and display the normal output

// This is required to prevent display of standard page elements (header, footer, etc) from the template and allow javascript code to run properly

// Do not add pages here unless it is from the standard osC and really should be there. If you have a special page that you don't want with template,

// Create a module sts_mypagename.php that returns an empty string as template filename, it will automatically switch off STS for this page.

if (strstr($scriptbasename, "popup")|| strstr($scriptbasename, "info_shopping_cart")) {

$this->display_template_output = false;

return;

}

// Check for module that will handle the template (for example module sts_index takes care of index.php templates)

$check_file = 'sts_' . $scriptbasename;

$modules_installed = explode (';', MODULE_STS_INSTALLED);

if (!in_array($check_file, $modules_installed))

$check_file = 'sts_default.php';

include_once (DIR_WS_MODULES.'sts/' . $check_file);

$classname=substr($check_file,0,strlen($check_file)-4);

$this->script=new $classname; // Create an object from the module

// If module existes but is disabled, use the default module.

if ($this->script->enabled==false) {

unset ($this->script);

include_once (DIR_WS_MODULES.'sts/sts_default.php');

$this->script = new sts_default; // Create an object from the module 

}



$this->template_file = $this->script->find_template(); // Retrieve the template to use

return $this->template_file;

}



function start_capture () {

// Start redirecting output to the output buffer, if template mode on.

if ($this->display_template_output) {

ob_start();

}

}



function stop_capture ($block_name='', $action='') {

// Store captured output to $sts_capture

if (!$this->display_template_output) return; // Do not process anything if we are not in using templates

$block = ob_get_clean(); // Get content and clean the buffer

if (!tep_not_null($block_name)) return; // Not need to continue if we don't want to save the buffer



switch($action) {

case 'box': 

$this->template[$block_name]= sts_strip_unwanted_tags($block, $block_name);

break;

default:

$this->template[$block_name] = $block;

} // switch

}



function restart_capture ($block_name='sts_empty', $action='') {

// Capture buffer, save it and start a new capture

if (!$this->display_template_output) return;

$this->stop_capture($block_name, $action);

$this->start_capture();

}



function capture_fields (){

// If we use template, ask to module what file(s) to include for building fields

if ($this->display_template_output) {

$fields_arr= explode(';', 'general.php;'.$this->script->capture_fields ());

}

return $fields_arr;

}



function read_template_file (){

// Purpose: Open Template file and read it

// Generate an error if the template file does not exist and return 'false'.

if (!file_exists($this->template_file)) {

print 'Template file does not exist: ['.$this->template_file.']';

return false;

}

// We use templates and the template file exists

// Capture the template, this way we can use php code inside templates

$this->start_capture(); // Start capture to buffer

require_once($this->template_file); // Includes the template, this way php code can be used in templates*/

$this->stop_capture('template_html');

return true;

} // End read_template_file



function replace (){

global $messageStack, $request_type;



if (!$this->display_template_output) return; // Go out if we don't use template

if (defined("STS_END_CHAR") == false) define ('STS_END_CHAR', ''); // An end char must be defined, even if empty.



// Load up the <head> content that we need to link up everything correctly. Append to anything that may have been set in sts_user_code.php

// Note that since v3.0, stylesheet is not defined here but in the template file, allowing different stylesheet for different template.

$this->template['headcontent'] = $this->template['headcontent'].'';

$this->template['headcontent'] = $this->template['headcontent'].'<meta http-equiv="Content-Type" content="text/html; charset=' . CHARSET . '">' . "\n"; 

$this->template['headcontent'] = $this->template['headcontent'].$this->template['headertags'];

$this->template['headcontent'] = $this->template['headcontent'].'<base href="' . (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG . '">' . "\n";

$this->template['headcontent'] = $this->template['headcontent'].get_javascript($this->template['applicationtop2header'],'get_javascript(applicationtop2header)');



$this->script->replace($this->template); // Module can make tricks here, just before replacing, like using own content template

// Add messages before the content

if ($messageStack->size('header') > 0) {

$this->template['content'] = $messageStack->output('header') . $this->template['content'];

}



// Manually replace the <!--$headcontent--> if present

$this->template['template_html'] = str_replace('<!--$headcontent-->', $this->template['headcontent'], $this->template['template_html']);

// Manually replace the <!--$extracss--> with template['extracss']

$this->template['template_html'] = str_replace('<!--$extracss-->', $this->template['extracss'], $this->template['template_html']);

// Automatically replace all the other template variables

if (STS_END_CHAR=='') { // If no end char defined for the placeholders, have to sort the placeholders.

uksort($this->template, "sortbykeylength"); // Sort array by string length, so that longer strings are replaced first

}

foreach ($this->template as $key=>$value) {

$this->template['template_html'] = str_replace('$' . $key . STS_END_CHAR , $value, $this->template['template_html']);

}

}

// *****************************************

// Functions added for debug

// ***************************************** 

function add_debug ($text, $br=true) {

// STS v4.1: Add debug text to the STS PLUS debug variable. If $br=false, then no line break added

$this->template['debug'].= $text . ($br ? "\n" : '');

}

} //end class

?>

[/size]

This is the sts.php file that came with the small STS v4.1 update. It is different from the sts.php file included in the small typo contribution. DO NOT COPY AND PASTE THE CODE ABOVE BECAUSE THE CODE WINDOW USED IN THIS FORUM REMOVES THE ACCURATE SPACES NEEDED IN THE CODE AND FORMATS EVERYTHING INCORRECTLY TO THE LEFT.

 

Once you change the sts.php file, go to your admin panel and remove the Sts Default module. Now, reinstall the Default module and set the use template to "true". Close your browser and then reopen to your web store. It should work for you. I don't know why this happend to you, but it appears the Default module included in the 4.1 update is buggy.

 

Bill Kellum

Edited by bkellum

Bill Kellum

 

Sounds Good Productions

STS Tutorials & more: STSv4.6, STS Add-ons (STS Power Pack), STS V4 Forum STS Forum FREE TEMPLATE

Link to comment
Share on other sites

wrong sts.php version was causing the double headers in my case
Bas, which sts.php file did you use? Was it the one from the April 14 small update contribution or did you bring the sts.php file over from your STS Plus 4.07 contribution?

 

This would be good to know.

 

Thanks,

 

Bill Kellum

Bill Kellum

 

Sounds Good Productions

STS Tutorials & more: STSv4.6, STS Add-ons (STS Power Pack), STS V4 Forum STS Forum FREE TEMPLATE

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

×
×
  • Create New...