Manually writing to Category tables

3 posts by 2 authors in: Forums > CMS Builder
Last Post: August 2, 2010   (RSS)

Re: [garyhoffmann] Manually writing to Category tables

By Chris - August 2, 2010

Hi Gary,

Wow, that's a tricky one. This is outside of what we normally offer for support, but I thought I'd try to help you out! :)

We have a utility function you can call which should sort everything out. Insert your new record with the parentCategory field filled out and bogus values (see below) for the special category fields, then call updateCategoryMetadata().

When you INSERT, I think you'll want to set the category fields like this:

globalOrder = 0,
siblingOrder = 99999999,
lineage = '',
depth = 0,
breadcrumb = ''


Then, immediately after inserting, call the function to set those values. Note that you'll need to set some globals first before you call this function:

global $escapedTableName, $schema;
$escapedTableName = mysql_escape( getTableNameWithPrefix('my_category_table') );
$schema = loadSchema('my_category_table');
updateCategoryMetadata();


I've tested this out here and it seems to work. I hope it works for you too!
All the best,
Chris

Re: [chris] Manually writing to Category tables

By garyhoffmann - August 2, 2010

Thank you - I appreciate it.

This is going back to one of the other posts I had about creating a ustyles.css file from a CMSB table. But, during initial development, I want to be able to use Dreamweaver to create the styles file and load that up into the database.

It all appears to be working great.

Thanks again, take care,
Gary.