Before I start, there will be quite a bit of back-and-forth between old and new versions going on here. I suggest that you keep a clean copy of the Addon code that you downloaded to refer to as you work. If necessary, go download a new copy and extract the files.
It may also help to use your file comparison program in some of the steps. I use Meld. There are many equivalent programs available, and most of them are free. Learn to use one; it'll save you a lot of time and trouble in the future.
The major change in osCommerce pages from 2.2x to 2.3x is the replacement of the top and bottom parts of the page by catalog/includes/template_top.php and /template_bottom.php. That means that your 2.2x Addon has a lot of extra code that needs to be removed, and then a link to the new template files needs to be added.
Let's start with the top part. Here's the part of a typical file we need to find:
Quote
$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_CONDITIONS));
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
<tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
<!-- body_text //-->
<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
<tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
<!-- body_text //-->
<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
Quote
$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_CONDITIONS));
?>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
?>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
Quote
$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_CONDITIONS));
require(DIR_WS_INCLUDES . 'template_top.php');
?>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
require(DIR_WS_INCLUDES . 'template_top.php');
?>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
Now to replace the bottom part of the file with template_bottom.php:
Quote
</tr>
</table></td>
<!-- body_text_eof //-->
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
</table></td>
</tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
</table></td>
<!-- body_text_eof //-->
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
</table></td>
</tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
Quote
</tr>
</table>
<?php
require(DIR_WS_INCLUDES . 'template_bottom.php');
require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
</table>
<?php
require(DIR_WS_INCLUDES . 'template_bottom.php');
require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
Quote
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
Now you may have noticed that the remaining center part of your page starts with <table ... > and ends with </table>. This is normal for a classic osCommerce page. In a very few cases this may be <div> and </div>. If yours doesn't look like one or the other, you have probably made a mistake somewhere. Go back and look at the original file again and fix your new version if needed.
There is one more thing that might happen to complicate your conversion: Your original Addon code may have added something to the top of the page that's not in the 2.3.x code. This will usually be a bit of JavaScript, but it could also be a stylesheet or similar code. This is a bit unusual, but some pages do have this. The way to find out is to compare the code in the original Addon page to the example I posted above. The part that you want to look at is between the <head> and </head> tags. There are only 4 lines to look at. Do this line by line, while ignoring minor changes in individual lines. What you are looking for is a line that occurs in your Addon that does not match anything in the above code. This line (or several lines in some cases) will usually be just above the </head> tag.
Let's say you found this added line in your page:
Quote
<script type="text/javascript" src="foo/bar.js"></script>
Fortunately there's a better way to do this. Find this line in your newly converted page:
Quote
require(DIR_WS_INCLUDES . 'template_top.php');
Quote
$head_tag .= '<script type="text/javascript" src="foo/bar.js"></script>' . "\n";
$oscTemplate->addBlock( $head_tag, 'header_tags' );
$oscTemplate->addBlock( $head_tag, 'header_tags' );
But wait, what happens if there are single quotes in the old code? That's rare, but if there are single quotes you have to escape them, like this: \' Just add that backslash in front of every single quote in the old code before you paste it into the new page. It's easier to see them that way.
Another possibility is that there may be multiple lines that you need to add. That's fine, just paste all of the lines between the single quotes like you did above. A multi-line addition might look like this:
Quote
$head_tag .= ' <script type="text/javascript">
$(function() {
$( "#accordion" ).accordion();
});' . "\n";
$oscTemplate->addBlock( $head_tag, 'header_tags' );
$(function() {
$( "#accordion" ).accordion();
});' . "\n";
$oscTemplate->addBlock( $head_tag, 'header_tags' );
Please keep any discussion here related to this Tip. I'm perfectly willing to answer questions if you're unclear about something I've said above, but I won't go off-topic.
Regards
Jim














