Hi Sara.
OK, I’ll try to explain, but this was very hard to do, much because I am still very new to MODx and have probably not done things the ’right’ way, and certainly not the most efficient way.
But it works, and I needed it in a hurry. I will do some work later and try to optimize some of the code when I add cart and customer functions.
I have only used the category/product functions, the contribution offer much more which I have not tested yet.
First you need the XML contribution for OsC:
CREX - OSCommerce XML
http://www.oscommerce.com/community/contributions,5198
Support for the contribution is here:
http://forums.oscommerce.com/index.php?showtopic=266505
There are some bugs in the code, so check out the forum before you start, if you don’t use my versions.
My versions include a few bugfixes, some expanded functions and some UTF8 cleaning of the OsC data among other stuff.
First you need to get this working using the crex_read.php script before you delve into MODx.
Then you need to make the crex_read.php into a MODx snippet, more or less.
I also made a snippet parsing out the XML data into either tables or unordered lists, depending on what I need for the various functions.
I wanted the categories to be hard coded in MODx so that I could have a static "header" page for each category, but I wanted dynamic subcategories and products. The subcategories are returned as lists, while the product listing is a table.
I use TV’s to send the category and product parameters to the snippet.
I include all the code I have on this, some of it is not very pretty, although working.
A few hints:
You need to set register_globals to ON. ( I know, it’s a bad idea, but OsC requires it in this version)
I use a fixed value TV in my static category pages in a call to the get_subcategories function.
A left container uses chunks to show the expanded subcategories under each category after they are clicked.
I had issues with double calls to OsC, which I could not resolve by other means than using a session variable to hold temporary results, in my case I chose to store the returned subcategories in a session variable. This does restrict direct linking to product listings, as the session will not be set and the query will return null and an empty listing. I made a workaround for that with a message saying that direct linking was not possible.
If you find a way to control two calls to OsC on the same page, it would be great. I didn’t have the time to pursue it.
Dataflow:
Category pages
I have static category pages as I said, I only have 6 or 7 so it’s ok. They are all containers.
The main content is a general description of the category, all in MODx.
The following TV’s are used:
OsC_Cpath: Any valid OsC category value, such as 20
OsC_Command: get_subcategories
Subcategories
The subcategories/product listing page is a child page for each Category page, not so efficient, but there you have it.
In my subcategory pages I use a placeholder as the Description: [+catname+]
(I use the same Title as the main category static page.)
The main content is just a snippet call: [!OsC!]
This returns the products in the given subcategory as a table
The following TV’s are used:
OsC_Cpath: @EVAL $up_Params; return $modx->runSnippet(’OsC_get_cpath’,$up_Params);
OsC_Command: get_category_products_ext
Chunks
I use one chunk for the leftcontent (categories) for each category, basically they are all the same, just differing on the category to expand. Again, very inefficient. Feel free to improve on it.
<dl class="nav3-grid">
<dt ><a href="[~95~]"> Category x </a></dt>
<dd>[!OsC_categories_select!]</dd>
<dt><a href="[~88~]"> Category x </a></dt>
<dt><a href="[~89~]"> Category x </a></dt>
<dt><a href="[~90~]"> Category x </a></dt>
<dt><a href="[~91~]"> Category x </a></dt>
<dt><a href="[~109~]"> Category x </a></dt>
<dt><a href="[~92~]"> Category x </a></dt>
<dt><a href="[~94~]"> Category x </a></dt>
<dt><a href="[~93~]"> Category x </a></dt>
<dt><a href="[~99~]"> Category x </a></dt>
I also use a snippet called thumbs for the images, it’s in the repository.
Some of the text in the code are in Norwegian, but those are just labels. Should not be a problem, but let me know if you need them translated.
I think that is all of it, the snippets and my version of the contribution are in the zip file.
Good luck.
Cheers,
Andreas