Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[contribution] Simple Template System (sts)


DiamondSea

Recommended Posts

A small problem: I cannot get the $specialfriendbox box to appear anywhere. Nor for that matter will the following boxes appear: $maninfobox $orderhistorybox $bestsellersbox

 

Can any one suggest why?

 

The $specialfriendbox appears only depending on the page viewed.

Link to comment
Share on other sites

I was under the impression that this was the box that allowed users to refer the site to a friend? Wouldn't this appear on the front page?

It tells a friend about a product and you'll find it in the product's page, otherwise the specials is shown.

Link to comment
Share on other sites

I just installed the STS and now am getting errors on my index.php page. The only other contribution I had installed was Header Tags Controller. I was installing STS because I do not want to use the standard OSC design. Here is the errors that I am getting:

 

Template file doesn't exist: []Can't open Template file: []

Warning: fread(): supplied argument is not a valid stream resource in /home/www/sommartimemarketplace/includes/sts_display_output.php on line 178

 

Warning: fclose(): supplied argument is not a valid stream resource in /home/www/sommartimemarketplace/includes/sts_display_output.php on line 179

 

Fatal error: main(): Failed opening required '' (include_path='.:/usr/local/php/share/pear') in /home/www/sommartimemarketplace/includes/sts_display_output.php on line 198

 

Here is the code in the sts_display_output.php file:

 

<?php
/*
$Id: sts_display_output.php,v 1.1 2005/07/25 18:19:27 stsdsea Exp $

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

Copyright (c) 2003 osCommerce

Released under the GNU General Public License
*/

/* 

 Simple Template System (STS) - Copyright (c) 2004 Brian Gallagher - [email protected]

*/

// Used for debugging, please don't change
$sts_version = "3.00 Beta 2";
$sts_osc_version = PROJECT_VERSION;
$sts_osc_version_required = "osCommerce 2.2-MS2";

// Set $templatedir and $templatepath (aliases) to current template path on web server, allowing for HTTP/HTTPS differences, removing the trailing slash
$template['templatedir'] = substr(((($request_type == 'SSL') ? DIR_WS_HTTPS_CATALOG : DIR_WS_HTTP_CATALOG) . STS_TEMPLATE_DIR),0,-1);
$template['templatepath'] = $template['templatedir'];

echo "<!-- Page layout by Simple Template System (STS) v$sts_version on $sts_osc_version - http://www.diamondsea.com/sts/ -->\n";

// Perform OSC version checking
if ($sts_osc_version != $sts_osc_version_required) {
 echo "STS was designed to work with OSC version [$sts_osc_version_required].  This is version [$sts_osc_version].\n";
}

$template['debug'] .= ''; // Define as blank if not already defined

/////////////////////////////////////////////
// SELECT HOW TO DISPLAY THE OUTPUT
/////////////////////////////////////////////
$display_template_output = 1;
$display_normal_output = 0;
$display_debugging_output = 0;
$display_version_output = 0;

// Override if we need to show a pop-up window
$scriptname = $_SERVER['PHP_SELF'];
$scriptname = getenv('SCRIPT_NAME');
$scriptbasename = substr($scriptname, strrpos($scriptname, '/') + 1);
// 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
if (strpos($scriptname, "popup") !== false || strpos($scriptname, "info_shopping_cart") !== false) {
$display_normal_output = 1;
$display_template_output = 0;
}


/////////////////////////////////////////////
// Allow the ability to turn on/off settings from the URL
// Set values to 0 or 1 as needed
/////////////////////////////////////////////

// Allow Template output control from the URL
if ($HTTP_GET_VARS['sts_template'] != "") {
$display_template_output = $HTTP_GET_VARS['sts_template'];
}

// Allow Normal output control from the URL
if ($HTTP_GET_VARS['sts_normal'] != "") {
$display_normal_output = $HTTP_GET_VARS['sts_normal'];
}

// Allow Debugging control from the URL
if ($HTTP_GET_VARS['sts_debug'] != "") {
$display_debugging_output = $HTTP_GET_VARS['sts_debug'];
}

// Allow Version control from the URL
if ($HTTP_GET_VARS['sts_version'] != "") {
$display_version_output = $HTTP_GET_VARS['sts_version'];
}

// Print out version number if needed
if ($display_version_output == 1 or $display_debugging_output == 1) {
print "STS_VERSION=[$sts_version]<br>\n";
print "OSC_VERSION=[$sts_osc_version]<br>\n";
}

/////////////////////////////////////////////
////// if product_info.php load data
/////////////////////////////////////////////
if ($scriptbasename == 'product_info.php') {
 require(STS_PRODUCT_INFO);
}

/////////////////////////////////////////////
///// Determine which template file to use
/////////////////////////////////////////////
$sts_template_array = array(
STS_DEFAULT_TEMPLATE,
STS_TEMPLATE_DIR . $scriptbasename . ".html",
);

// Are we in the index.php script?  If so, what is our Category Path (cPath)?
if ($scriptbasename == "index.php") {
 // If no cPath defined, default to 0 (the home page)
 if ($cPath == "") {
$sts_cpath = 0; 
 } else {
	$sts_cpath = $cPath;
 }

 // If we are doing a search by manufacturer, use the "index.php_mfr.html" template
 if (isset($HTTP_GET_VARS['manufacturers_id'])) {
	$sts_cpath = "mfr";
 }

 // Split cPath into parts and check for them individually
 $cpath_parts = (split("_", $sts_cpath));
 foreach ($cpath_parts as $a) {
	array_push($sts_template_array, STS_TEMPLATE_DIR . "index.php_$a.html");
 }

 // Look for category-path-specific template file like "index.php_1_17.html"
 array_push($sts_template_array, STS_TEMPLATE_DIR . "index.php_$sts_cpath.html");

 // Check for manufacturer-specific templates
 if (isset($HTTP_GET_VARS['manufacturers_id'])) {
array_push($sts_template_array, STS_TEMPLATE_DIR . "index.php_mfr_" . $HTTP_GET_VARS['manufacturers_id'] . ".html");
 }


}

// Check for Product_Info templates by Product ID and cPath
if ($scriptbasename == "product_info.php") {
 $cpath_parts = (split("_", $cPath));
 foreach ($cpath_parts as $a) {
	array_push($sts_template_array, STS_TEMPLATE_DIR . "product_info.php_c$a.html");
 }
	array_push($sts_template_array, STS_TEMPLATE_DIR . "product_info.php_c$cPath.html");
	array_push($sts_template_array, STS_TEMPLATE_DIR . "product_info.php_${template['productid']}.html");
}

// Select the highest-order template to use
foreach ($sts_template_array as $checkfile) {
 if ($display_debugging_output) {
print "Checking for Template: $checkfile -> " . (file_exists($checkfile) ? "Found":"Not Found") . "<br>\n";
 }

 if (file_exists($checkfile)) {
$sts_template_file = $checkfile;
 }
}

// Active template is now in $sts_template_file
if ($display_debugging_output) {
 print "Active Template is [$sts_template_file]<br>\n";
}

// Open Template file and read into a variable
if (! file_exists($sts_template_file)) {
 echo "Template file doesn't exist: [$sts_template_file]";
}  else {
 echo "<!-- Using Template File [$sts_template_file) -->\n";
}

// Used to read and check for $url_ and $urlcat_ variables
$sts_read_template_file = 1;  
// Used for including and executing inline PHP and displaying HTML
$sts_include_template_file = 1;

// Old method of reading in html file
if ($sts_read_template_file) {
if (! $fh = fopen($sts_template_file, 'r')) {
echo "Can't open Template file: [$sts_template_file]";
}

$sts_template_file_contents = fread($fh, filesize($sts_template_file));
fclose($fh);
}

// See if there are any $url_ or $urlcat_ variables in the template file, if so, flag to read them
if (strpos($sts_template_file_contents, "\$url_") or strpos($sts_template_file_contents, "\$urlcat_") ) {
$sts_need_url_tags = 1;
} else {
$sts_need_url_tags = 0;
}


// new method of including template file as executable code and capturing the output
if ($sts_include_template_file) {
require(STS_START_CAPTURE);
// require("phptest.php");
// print "require($sts_template_file);";

// We could just eval($sts_template_file_contents) instead, but we would then lose the optimization
// benefits that a PHP accellerator would offer in caching the compiled code, so we require() the file instead
require($sts_template_file);
$sts_block_name = 'template_html';
require(STS_STOP_CAPTURE);
$template_html = $sts_block['template_html'];
}


/////////////////////////////////////////////
////// Run any user code needed
/////////////////////////////////////////////
require(STS_USER_CODE);

/////////////////////////////////////////////
////// Set up template variables
/////////////////////////////////////////////

/////////////////////////////////////////////
////// Capture <title> and <meta> tags
/////////////////////////////////////////////

// STS: ADD: Support for WebMakers.com's Header Tag Controller contribution
 // Capture the output
 require(STS_START_CAPTURE);

 // BOF: WebMakers.com Changed: Header Tag Controller v1.0
 // Replaced by header_tags.php
 if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) {
require(DIR_WS_FUNCTIONS . 'clean_html_comments.php');
require(DIR_WS_FUNCTIONS . 'header_tags.php');
require(DIR_WS_INCLUDES . 'header_tags.php');
 } else {
echo "<title>" . TITLE . "</title>";
 }
 // EOF: WebMakers.com Changed: Header Tag Controller v1.0

 $sts_block_name = 'headertags';
 require(STS_STOP_CAPTURE);

// STS: EOADD: Support for WebMakers.com's Header Tag Controller contribution

/////////////////////////////////////////////
////// Set up template variables
/////////////////////////////////////////////

 $template['sid'] =  tep_session_name() . '=' . tep_session_id();
 $template['sysmsgs'] = $messageStack->output('header');

 // Strip out <title> variable
 $template['title'] = str_between($sts_block['headertags'], "<title>", "</title>");

 // 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
 // Prevent page caching
 $template['headcontent'] .= '<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"><META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"><META HTTP-EQUIV="Expires" CONTENT="-1">';
 $template['headcontent'] .= '<meta http-equiv="Content-Type" content="text/html; charset=' . CHARSET . '">' . "\n"; 
 $template['headcontent'] .= $sts_block['headertags'];
 $template['headcontent'] .= '<base href="' . (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG . '">' . "\n";
 // $template['headcontent'] .= '<link rel="stylesheet" type="text/css" href="stylesheet.css">' . "\n";
 $template['headcontent'] .= get_javascript($sts_block['applicationtop2header'],'get_javascript(applicationtop2header)');


 // Note: These values lifted from the stock /catalog/includes/header.php script's HTML
 // catalogurl: url to catalog's home page
 // catalog: link to catalog's home page
 $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);

 $template['myaccountlogo'] = '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . tep_image(DIR_WS_IMAGES . 'header_account.gif', HEADER_TITLE_MY_ACCOUNT) . '</a>';
 $template['urlmyaccountlogo'] = tep_href_link(FILENAME_ACCOUNT, '', 'SSL');

 $template['cartlogo'] = '<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . tep_image(DIR_WS_IMAGES . 'header_cart.gif', HEADER_TITLE_CART_CONTENTS) . '</a>';
 $template['urlcartlogo'] = tep_href_link(FILENAME_SHOPPING_CART);

 $template['checkoutlogo'] = '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . tep_image(DIR_WS_IMAGES . 'header_checkout.gif', HEADER_TITLE_CHECKOUT) . '</a>';
 $template['urlcheckoutlogo'] = tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL');

 $template['breadcrumbs'] = $breadcrumb->trail(' » ');

 if (tep_session_is_registered('customer_id')) {
$template['myaccount'] = '<a href=' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . ' class="headerNavigation">' . HEADER_TITLE_MY_ACCOUNT . '</a>';
$template['urlmyaccount'] = tep_href_link(FILENAME_ACCOUNT, '', 'SSL');
$template['logoff'] = '<a href=' . tep_href_link(FILENAME_LOGOFF, '', 'SSL')  . ' class="headerNavigation">' . HEADER_TITLE_LOGOFF . '</a>';
$template['urllogoff'] = tep_href_link(FILENAME_LOGOFF, '', 'SSL');
$template['myaccountlogoff'] = $template['myaccount'] . " | " . $template['logoff'];
 } else {
$template['myaccount'] = '<a href=' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . ' class="headerNavigation">' . HEADER_TITLE_MY_ACCOUNT . '</a>';
$template['urlmyaccount'] = tep_href_link(FILENAME_ACCOUNT, '', 'SSL');
$template['logoff'] = '';
$template['urllogoff'] = '';
$template['myaccountlogoff'] = $template['myaccount'];
 }

 $template['cartcontents']	= '<a href=' . tep_href_link(FILENAME_SHOPPING_CART) . ' class="headerNavigation">' . HEADER_TITLE_CART_CONTENTS . '</a>';
 $template['urlcartcontents'] = '<a href=' . tep_href_link(FILENAME_SHOPPING_CART) . ' class="headerNavigation">' . HEADER_TITLE_CART_CONTENTS . '</a>';

 $template['checkout'] = '<a href=' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . ' class="headerNavigation">' . HEADER_TITLE_CHECKOUT . '</a>';
 $template['urlcheckout'] = tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL');

/////////////////////////////////////////////
////// Create custom boxes
/////////////////////////////////////////////
 $template['categorybox'] = strip_unwanted_tags($sts_block['categorybox'], 'categorybox');
 $template['manufacturerbox'] = strip_unwanted_tags($sts_block['manufacturerbox'], 'manufacturerbox');
 $template['whatsnewbox'] = strip_unwanted_tags($sts_block['whatsnewbox'], 'whatsnewbox');
 $template['searchbox'] = strip_unwanted_tags($sts_block['searchbox'], 'searchbox');
 $template['informationbox'] = strip_unwanted_tags($sts_block['informationbox'], 'informationbox');
 $template['cartbox'] = strip_unwanted_tags($sts_block['cartbox'], 'cartbox');
 $template['maninfobox'] = strip_unwanted_tags($sts_block['maninfobox'], 'maninfobox');
 $template['orderhistorybox'] = strip_unwanted_tags($sts_block['orderhistorybox'], 'orderhistorybox');
 $template['bestsellersbox'] = strip_unwanted_tags($sts_block['bestsellersbox'], 'bestsellersbox');
 $template['specialfriendbox'] = strip_unwanted_tags($sts_block['specialfriendbox'], 'specialfriendbox');
 $template['reviewsbox'] = strip_unwanted_tags($sts_block['reviewsbox'], 'reviewsbox');
 $template['languagebox'] = strip_unwanted_tags($sts_block['languagebox'], 'languagebox');
 $template['currenciesbox'] = strip_unwanted_tags($sts_block['currenciesbox'], 'currenciesbox');
 $template['content'] = strip_content_tags($sts_block['columnleft2columnright'], 'content');
 // Prepend any error/warning messages to $content
 if ($messageStack->size('header') > 0) {
$template['content'] = $messageStack->output('header') . $template['content'];
 }
 $template['date'] = strftime(DATE_FORMAT_LONG);
 $template['numrequests'] = $counter_now . ' ' . FOOTER_TEXT_REQUESTS_SINCE . ' ' . $counter_startdate_formatted;
 $template['counter'] = $sts_block['counter'];
 $template['footer'] = $sts_block['footer'];
 $template['banner'] = $sts_block['banner'];


/////////////////////////////////////////////
////// Get Categories
/////////////////////////////////////////////

if ($sts_need_url_tags) {
print "<!-- STS: Reading $url_ and $urlcat_ tags, recommend not using them -->";
$get_categories_description_query = tep_db_query("SELECT categories_id, categories_name FROM " . TABLE_CATEGORIES_DESCRIPTION);
// Loop through each category (in each language) and create template variables for each name and path
while ($categories_description = tep_db_fetch_array($get_categories_description_query)) {
	  $cPath_new = tep_get_path($categories_description['categories_id']);
	  $path = substr($cPath_new, 6); // Strip off the "cPath=" from string

	  $catname = $categories_description['categories_name'];
	  $catname = str_replace(" ", "_", $catname); // Replace Spaces in Category Name with Underscores

	  $template["cat_" . $catname] = tep_href_link(FILENAME_DEFAULT, $cPath_new);
	  $template["urlcat_" . $catname] = tep_href_link(FILENAME_DEFAULT, $cPath_new);
	  $template["cat_" . $path] = tep_href_link(FILENAME_DEFAULT, $cPath_new);
	  $template["urlcat_" . $path] = tep_href_link(FILENAME_DEFAULT, $cPath_new);

	  // print "<b>template[" . $categories_description['categories_name'] . "]=" . $template[$categories_description['categories_name']] . "<br>template[" . $path . "]=" . $template[$path] . "</b>";
}
}

/////////////////////////////////////////////
////// Display Template HTML
/////////////////////////////////////////////

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

 // Manually replace the <!--$headcontent--> if present
$template_html = str_replace('<!--$headcontent-->', $template['headcontent'], $template_html);

 // Automatically replace all the other template variables
 foreach ($template as $key=>$value) {
$template_html = str_replace('$' . $key, $value, $template_html);
 }

 if ($display_template_output == 1) {
echo $template_html;
 }


/////////////////////////////////////////////
////// Display HTML
/////////////////////////////////////////////
if ($display_normal_output == 1) {
 echo $sts_block['applicationtop2header'];
 echo $sts_block['header'];


 echo $sts_block['header2columnleft'];

 // print column_left stuff
 echo $sts_block['categorybox'];
 echo $sts_block['manufacturerbox'];
 echo $sts_block['whatsnewbox'];
 echo $sts_block['searchbox'];
 echo $sts_block['informationbox'];

 echo $sts_block['columnleft2columnright'];

 // print column_right stuff
 echo $sts_block['cartbox'];
 echo $sts_block['maninfobox'];
 echo $sts_block['orderhistorybox'];
 echo $sts_block['bestsellersbox'];
 echo $sts_block['specialfriendbox'];
 echo $sts_block['reviewsbox'];
 echo $sts_block['languagebox'];
 echo $sts_block['currenciesbox'];

 echo $sts_block['columnright2footer'];

 // print footer
 echo $sts_block['content'];
 echo $sts_block['counter'];
 echo $sts_block['footer'];
 echo $sts_block['banner'];
}
/////////////////////////////////////////////
////// End Display HTML
/////////////////////////////////////////////

if ($display_debugging_output == 1) {
 // Print Debugging Info
 print "\n<pre><hr>\n";
 print "STS_VERSION=[" . $sts_version . "]<br>\n";
 print "OSC_VERSION=[$sts_osc_version]<br>\n";
 print "STS_TEMPLATE=[" . $sts_template_file . "]<hr>\n";
 // Replace $variable names in $sts_block_html_* with variables from the $template array
 foreach ($sts_block as $key=>$value) {
print "<b>\$sts_block['$key']</b><hr>" . htmlspecialchars($value) . "<hr>\n";
 }

 foreach ($template as $key=>$value) {
print "<b>\$template['$key']</b><hr>" . htmlspecialchars($value) . "<hr>\n";
 }

}

if ($display_normal_output == 1) {
 echo $sts_block['footer2applicationbottom'];
}

// STRIP_UNWANTED_TAGS() - Remove leading and trailing <tr><td> from strings
function strip_unwanted_tags($tmpstr, $commentlabel) {
 // Now lets remove the <tr><td> that the require puts in front of the tableBox
 $tablestart = strpos($tmpstr, "<table");

 // If empty, return nothing
 if ($tablestart < 1) {
  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("</table>"), 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";
}


// STRIP_CONTENT_TAGS() - Remove text before "body_text" and after "body_text_eof"
function strip_content_tags($tmpstr, $commentlabel) {
 // Now lets remove the <tr><td> that the require puts in front of the tableBox
 $tablestart = strpos($tmpstr, "<table");
 $formstart = strpos($tmpstr, "<form");

 // If there is a <form> tag before the <table> tag, keep it
 if ($formstart !== false and $formstart < $tablestart) {
 $tablestart = $formstart;
 $formfirst = true;
 }

 // If empty, return nothing
 if ($tablestart < 1) {
	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);

 if ($formfirst == true) {
$tableend = strpos($tmpstr, strrev("</form>"), 1);
 } else {
$tableend = strpos($tmpstr, strrev("</table>"), 1);
 } 

 $tmpstr = substr($tmpstr, $tableend);  // strip off stuff after <!-- body_text_eof //-->

 // 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";
}


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\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";
}

// Return the value between $startstr and $endstr in $tmpstr
function str_between($tmpstr, $startstr, $endstr) {
 $startpos = strpos($tmpstr, $startstr);

 // If empty, return nothing
 if ($startpos === false) {
	return  "";
 }

 $tmpstr = substr($tmpstr, $startpos + strlen($startstr)); // strip off stuff before $start

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

 $endpos = strpos($tmpstr, strrev($endstr), 1);

 $tmpstr = substr($tmpstr, $endpos + strlen($endstr));  // strip off stuff after </table>

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

 return  $tmpstr;
}

function sortbykeylength($a,$b) {
 $alen = strlen($a);
 $blen = strlen($b);
 if ($alen == $blen) $r = 0;
 if ($alen < $blen) $r = 1;
 if ($alen > $blen) $r = -1;
 return $r;
}

?>

Link to comment
Share on other sites

Hey STS people..

 

I have been using STS for awhile now and love it. My next step is to have the category menu turned graphical buttons.

 

Does anyone know of a Contrib that will do this and work with STS?

 

In short, I want to have graphical buttons for each category in stead of a list of text.

 

Please help been searching for 2 days.

 

Thanks

johnny

Link to comment
Share on other sites

I have searched the forum and cannot locate an answer to this scenario.

 

I have a site that is running STS.

I want to have a custom product_info page for a specific category only.

 

I have 256 items in 100 different categories. I want to display a special message on only one Category for 2 weeks. How can I achieve this using sts? Could I make a special product_info.php page for just this category?

Need Hosting? Just ask!

Link to comment
Share on other sites

GOT IT!!!

 

The issue of the images not showing up when going into SSL pages on a shared SSL .... play around with placing the following code in you head tag

 

<base href="http://www.yourdomain.com/">... it works!!!

 

Cheers,

 

Tim

 

Hi Tim,

 

Can you be more specific on how you solved the problem? I actually have this problem in my admin where no images will show up because of my shared ssl and I'm hoping whatever you did might help me to solve my problem...this has been months and months now and no one in the forum seems to know how to fix. Any direction you can give me to how you solved your problem will be most helpful!

 

Billie :thumbsup:

Link to comment
Share on other sites

Hi

I have STS installed and running sweet, you can take a look HERE

Can someone please give me step by step instructions or a link to exactly how to add header tag controller.

Am I correct in thinking HTC will make its own meta tags from the product info. What is the best for search engine rankings on individual products page.

I am a newbie so please be gentle

 

Brian

Link to comment
Share on other sites

Hey STS people..

 

I have been using STS for awhile now and love it. My next step is to have the category menu turned graphical buttons.

 

Does anyone know of a Contrib that will do this and work with STS?

 

In short, I want to have graphical buttons for each category in stead of a list of text.

 

Please help been searching for 2 days.

 

Thanks

johnny

I don't remember the name of the contribution you want but I'm posting here the categories.php file I use at my site that does the thing you want (replace text with image), so you can replace it with your old one (remember to backup your old one first!). The only thing I found is that if you enable cache your categories may not be displayed correctly.

 

<?php
/*
 $Id: categories.php,v 1.20 2002/06/05 19:18:22 dgw_ Exp $

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

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License
*/

 function tep_show_category($counter) {
global $foo, $categories_string, $id, $aa;

for ($a=0; $a<$foo[$counter]['level']; $a++) {
//	  $categories_string .= "??";
//			$categories_string .= "??";
}

//kreseczki start
  if ($foo[$counter]['level'] == 0)
{
	if ($aa == 1)
	{
// odchaszowac Ώeby dostaζ kreseczkκ	
//		$categories_string .= "<hr noshade size=1>";
 $categories_string .= '<img src="images/pixel_silver.gif" border="0" alt="" width="100%" height="1"><br><img src="images/pixel_trans.gif" border="0" alt="" width="100%" height="1">';
	}
	else
	{$aa=1;}

}
//kreseczki koniec


// display category name
// $categories_string .= $foo[$counter]['name'];
//  Eger alt kategorileri veya Asama0 olanalara varsa OK ekler
if (tep_has_category_subcategories($counter) || $foo[$counter]['level'] == 0) {
	if ( ($id) && (in_array($counter, $id)) ) {
	// display category name
	$categories_string .= '<table class="categ"><tr><td class="categ">' . tep_image(DIR_WS_IMAGES . 'categories/arrow_down.gif', '', '9', '9') . "?</td>";
	} else {
	// display category name
	$categories_string .= '<table class="categ"><tr><td class="categ">' .tep_image(DIR_WS_IMAGES . 'categories/arrow_right.gif', '', '9', '9') . "?</td>";
	}
} else {
$categories_string .= '<table class="categ"><tr><td class="categ">??' .tep_image(DIR_WS_IMAGES . 'categories/arrow_bullet.gif', 'nokta', '9', '9') . "</td>";
}


$categories_string .= '<td class="categ"><a href="';

if ($foo[$counter]['parent'] == 0) {
  $cPath_new = 'cPath=' . $counter;
} else {
  $cPath_new = 'cPath=' . $foo[$counter]['path'];
}

$categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new);
$categories_string .= '">';

if ( ($id) && (in_array($counter, $id)) ) {
  $categories_string .= '<b>';
}

//nazwa kategorii
$categories_string .= $foo[$counter]['name'];



if ( ($id) && (in_array($counter, $id)) ) {
  $categories_string .= '</b>';
}

if (tep_has_category_subcategories($counter)) {
  $categories_string .= '?';
}

$categories_string .= '</a>';

if (SHOW_COUNTS == 'true') {
  $products_in_category = tep_count_products_in_category($counter);
  if ($products_in_category > 0) {
	$categories_string .= '?(' . $products_in_category . ')';
  }
}

  // $categories_string .= '<br>';
  $categories_string .= '</td></tr></table>';

if ($foo[$counter]['next_id']) {
  tep_show_category($foo[$counter]['next_id']);
}
 }
?>
<!-- categories //-->
	  <tr>
		<td>
<?php
 $info_box_contents = array();
 $info_box_contents[] = array('align' => 'left');
 new infoBoxHeading($info_box_contents, false, false);

 $categories_string = '';

 $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . $languages_id ."' order by sort_order, cd.categories_name");
 while ($categories = tep_db_fetch_array($categories_query))  {
$foo[$categories['categories_id']] = array(
									'name' => $categories['categories_name'],
									'parent' => $categories['parent_id'],
									'level' => 0,
									'path' => $categories['categories_id'],
									'next_id' => false
								   );

if (isset($prev_id)) {
  $foo[$prev_id]['next_id'] = $categories['categories_id'];
}

$prev_id = $categories['categories_id'];

if (!isset($first_element)) {
  $first_element = $categories['categories_id'];
}
 }

 //------------------------
 if ($cPath) {
$id = split('_', $cPath);
reset($id);
while (list($key, $value) = each($id)) {
  $new_path .= $value;
  unset($prev_id);
  unset($first_id);
  $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . $value . "' and c.categories_id = cd.categories_id and cd.language_id='" . $languages_id ."' order by sort_order, cd.categories_name");
  $category_check = tep_db_num_rows($categories_query);
  while ($row = tep_db_fetch_array($categories_query)) {
	$foo[$row['categories_id']] = array(
										'name' => $row['categories_name'],
										'parent' => $row['parent_id'],
										'level' => $key+1,
										'path' => $new_path . '_' . $row['categories_id'],
										'next_id' => false
									   );

	if (isset($prev_id)) {
	  $foo[$prev_id]['next_id'] = $row['categories_id'];
	}

	$prev_id = $row['categories_id'];

	if (!isset($first_id)) {
	  $first_id = $row['categories_id'];
	}

	$last_id = $row['categories_id'];
  }
  if ($category_check != 0) {
	$foo[$last_id]['next_id'] = $foo[$value]['next_id'];
	$foo[$value]['next_id'] = $first_id;
  }

		 $new_path .= '_';
}
 }

 tep_show_category($first_element);

 $info_box_contents = array();
 $info_box_contents[] = array('align' => 'left',
						   'text'  => $categories_string
						  );
 new infoBox($info_box_contents);
?>
		</td>
	  </tr>
<!-- categories_eof //-->

There's a diference between living & BEING ALIVE!

Link to comment
Share on other sites

Is there a STS which does not require ?register_globals? enabled ???

 

I have the patched version of oscmmerce installed on my server and it works fine

 

However as soon as I install the STS I receive the error ?FATAL ERROR: register_globals is disabled in php.ini, please enable it!"

 

 

Please help !!

 

:thumbsup:

Link to comment
Share on other sites

Hello friends, plz guide me through the data dump

 

I have osCommerce 2.2-MS2 installed on a shared Linux Apache Server version 1.3.33 (Unix) running php version 4.3.11 I do not have SSL certificate.

 

I wish to customize the look of the online store. what do I do? what do I install?

 

Thanks a bunch

Link to comment
Share on other sites

Hi all,

Got the header tag controller installed on second attempt, it rocks, follow the instructions as listed but do not touch any of the 35 or so files they mention to modify STS does that automatically, be careful on your cutting and pasting and you will be fine.

 

NEXT PROJECT

 

What is the best thumbnail contribution to install with STS I need my picture load times slashed

 

Happy at my work

Brian

After Dark Sensations

Link to comment
Share on other sites

I recently installed STS per the instructions. I modified the STS_Templates.html file and the main page looks like I want, but when clicking further into the page, none of the change carry forward except those done in the .css. Borders, images, infoboxes all are unchanged. Am I modifying the correct Templates.html file? Where should I define the $headcontents (is this what is causing the problems?)

Link to comment
Share on other sites

Hello friends, plz guide me through the data dump

 

I have osCommerce 2.2-MS2 installed on a shared Linux Apache Server version 1.3.33 (Unix) running php version 4.3.11 I do not have SSL certificate.

 

I wish to customize the look of the online store. what do I do? what do I install?

 

Thanks a bunch

 

Could someone point me to where and what I need to install, the contribution lists so many

 

 

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

 

thx

Link to comment
Share on other sites

Could someone point me to where and what I need to install, the contribution lists so many

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

 

thx

 

The latest STS Full package is Simple Template System (STS) v3.00 Beta 2 released from the original author DiamonSea. It's beta but it works fine... If you don't wanna use this cause it's beta and it's certain that the standard version should be released sometime, maybe you should use an older version and upgrade later. If you want a good version try using this: Simple Template System (STS) v2.01 and then apply the patch using this: STS 2.01 Bug fixes; and you're done. Now if you use more contribs use the appropriate patch for each contrib.

There's a diference between living & BEING ALIVE!

Link to comment
Share on other sites

Hi all,

 

I just installed this contrib and love it so far, but I have a small problem I used to have this little contrib link:ShowNewPrice installed and now that I have STS it stoped to work. I was wondering if anyone had this installed and managed to get it to work with STS, or maybe someone can help me figure it out.

 

Thanks in advance.

Link to comment
Share on other sites

What triggers the updates to the .php files? My product_info.php is not updating with changes made to the sts_template.html file. What triggers the updates and when is it triggered. I have only modified sts_templates/mysite/sts_template.html. All pages reflect the changes except for product_info. Click Here to see.

Link to comment
Share on other sites

What triggers the updates to the .php files? My product_info.php is not updating with changes made to the sts_template.html file. What triggers the updates and when is it triggered. I have only modified sts_templates/mysite/sts_template.html. All pages reflect the changes except for product_info. Click Here to see.

 

 

From what I saw you are using product_info.php.html template file for your product info page and not sts_template.html file. Edit the product_info.php.html istead and you're done! If you want to see for yourself just right click at your website -> view source and look at the very first two lines. It says:

<!-- Page layout by Simple Template System (STS) v3.00 Beta 2 on osCommerce 2.2-MS2 - http://www.diamondsea.com/sts/ -->
<!-- Using Template File [includes/sts_templates/mysite/product_info.php.html) -->

There's a diference between living & BEING ALIVE!

Link to comment
Share on other sites

I see what you are talking about. Is it a problem that the product_info file is not being updated by sts_template, or is the contribution designed to have a different product page than all the other? (based on the contribution description, I edit 1 html file, this would be two)

 

If the correct solution is to modify the product_info file, then that is easily done, but is this a band-aid solution to fix a flaw in my installation? The important thing is for everything to run as it is designed to do.

 

Thanks for your help.

Link to comment
Share on other sites

What I do wrong??

 

This is what I have done:

 

1) Install Clean MS2.2 version

2) Test and see if it works

3) Go into /catalog/includes

4) Extract all the STS3 files from the ZIP file, preserving the directory structure.

5) Copy the define statements from the end of configure-SAMPLE.php to your working configure.php file

6) Test and see if it works

7) Done.

 

Then I changed my sts_template.html, but nothing happened. It allways shows the basic template.

My Store

 

Can someone help?

Link to comment
Share on other sites

working greet! sts turns oscommerce into something really nice...but i wonder how i could integrate the module article manager.

 

it was quite easy before...but now...i do not know how to convert this instruction to use with sts :

 

In includes/column_left.php or column_right.php (depending on what side you want the boxes):

 

Look for:

 

require(DIR_WS_BOXES . 'reviews.php');

 

Add immediately below (or place in your own desired order):

 

// Article Manager

require(DIR_WS_BOXES . 'authors.php');

require(DIR_WS_BOXES . 'articles.php');

 

ALTERNATIVELY: use Info Box Admin to position the boxes if you have that installed.

 

does anyone can help me ? B)

Link to comment
Share on other sites

One major question.

 

My site : Jagged

 

Uses STS 1.3 I have been working on this site for some time now, and would like to upgrade to the newest version of STS. Is this possible with out loosing my current template? And how much of a job is it?

 

My second question is about default images for both catagory and products. Like a "No Image Available" default image to show if none has been uploaded. Iv tried some contribs, but none of them have worked so far. If any one has any good ones please let me know. Im also using the newest OTF Auto Thumbnailer w/ GD. If that helps out at all.

 

Thanks

Link to comment
Share on other sites

working greet! sts turns oscommerce into something really nice...but i wonder how i could integrate the module article manager.

 

it was quite easy before...but now...i do not know how to convert this instruction to use with sts :

does anyone can help me ? B)

 

OK here we go... This is what you should do:

 

Open column_right.php:

###Add:###

// Article Manager

require(DIR_WS_BOXES . 'authors.php');

// STS: ADD

$sts_block_name = 'authorsbox';

require(STS_RESTART_CAPTURE);

// STS: EOADD

 

require(DIR_WS_BOXES . 'articles.php');

// STS: ADD

$sts_block_name = 'articlesbox';

require(STS_RESTART_CAPTURE);

// STS: EOADD

 

Open sts_display_output:

###Add###

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

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

 

Then you have to enter:

 

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

 

into the sts_user_code.php file also. After doing that, the boxes work.

Edited by Z3RatuL

There's a diference between living & BEING ALIVE!

Link to comment
Share on other sites

What triggers the updates to the .php files? My product_info.php is not updating with changes made to the sts_template.html file. What triggers the updates and when is it triggered. I have only modified sts_templates/mysite/sts_template.html. All pages reflect the changes except for product_info. Click Here to see.

 

OK, Ive been reading this for 2 days and I just must be missing something simple. I have STS3 beta 2 installed and working with the sts_template.html file.

 

I want to have a different layout for the categories and products but nothing I do seems to make sts read the index_0 or product.info file in the mysite folder. Yes, I know I'm stupid but please can someone just spell it out to me what I'm not doing??

Edited by mickgraham
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...