Articles » Administrator » Integrating osCommerce into Fundanemt
Author

Nikolai Gjerløff owns NGSoft which specializes in web programming and database engineering.

Website
E-mail

Integrating Fundanemt into osCommerce

by Nikolai Gjerløff, Oct 2005

These notes describe how you can insert a Fundanemt content area and a Fundanemt generated top-menu into an osCommerce webshop.

The original idea was to do the opposite, but because Fundanemt is quite flexible, and osCommerce turned out to be extremely inflexible, this was by far the easiest way.

These notes are based on OsCommerce version 2.2 Milestone 2, and FundaNemt version 2.2 CVS.

At this point it is assumed that you have installed osCommerce and Fundanemt to the same folder - there aren't any file-collisions, as Fundanemt stays inside its fundanemt/ folder tree.

osCommerce relies on a varity of different files for the different shop functions - index.php is used for displaying its front page, as well as products and categories - fortunately they include header.php, footer.php, column_left.php and column_right.php from the includes/ folder, and these contain some of the common layout.

As osCommerce has a very poor seperation between system code and layout, the changes you make will most likely need to be done every time you update osCommerce - so it is wise to keep note of them, and keep them confined to as few files as possible.

It is possible to include Fundanemt in osCommerce by modifying two files - we need to insert the initilization code and the menu in header.php, and the content area in index.php.

header.php

First we need to include html.class from our fundanemt-installation, and initialize the parser, for example:

<?php
include("fundanemt/fundaClient/html.class");

$parser = new html(1,"My Site");
?>

Then we need to define the style of our top-menu - here is an example:

<?php
  $arrayMenuStyle
[1]['IOO'] = '<a class="menulink" href="/index.php?ID=PAGEID">TITLE</a> | ';
  
$arrayMenuStyle[1]['IOI'] = '<a class="menulink" href="/index.php?ID=PAGEID">TITLE</a> | ';
  
$arrayMenuStyle[1]['OOO'] = '<a class="menulink" href="/index.php?ID=PAGEID">TITLE</a> | ';
  
$arrayMenuStyle[1]['OOI'] = '<a class="menulink" href="/index.php?ID=PAGEID">TITLE</a> | ';
?>

You may note, that the usual 'href="URL"' has been replaced by 'href="/index.php?ID=PAGEID"' - this is because the menu inserted in header.php has to generate links to index.php no matter which of the shop-function pages it is included on - and URL will always generate links to the page the menu is inserted on.

Finally, the actual menu must be inserted - you will no doubt need to make some changes to the HTML code to make it look the way you want it. Write the following where you want the menu:

<?php $parser->printMenu($arrayMenuStyle); ?>

index.php

Find the section of the file that displays the default page - it starts like this:

<?php
  
} else { // default page
?>

After this there is a <td ..> - and that is the beginning - delete everything inside this <td></td> block - it ends many lines below with:

<?php
    
include(DIR_WS_MODULES FILENAME_UPCOMING_PRODUCTS);
?>
        </table></td>
      </tr>
    </table></td>

The matching </td> is the last one of them.

The block between these two must be deleted, and in its place you can put the fundanemt content:

<?php $parser->printSiteContent();?>

An unfortunate side-effect is that the upcomming products and new products listing that are usually displayed on the front-page are removed - if you need them, you must find some other place to display them.