Sue wrote an earlier post about Webcrossing's object-oriented database, and the built-in objects that support forums. Objects representing folders, discussions, and messages descend from the parent Stored, and they inherit properties and methods from it that describe each object and its content and make manipulation easy.
There's another kind of inheritance available to you, one that depends on how you decide to structure your forum hierarchy. Every node you create, whether a folder, or a discussion, or an object you prototype yourself, has a parent in the forum hierarchy, analogous to the directory structure on a hard drive. You can define custom properties for any individual node. And then it's trivial for the node's descendents to access those properties.
Using Webcrossing's server-side javascript you could, for example, associate a folder with an external url, just by naming the property and setting it to a value:
myNode.externalUrl = 'http://www.someotherplace.com/somewhere';
Using Webcrossing's hierarchy support, that property is now available to any child of the node without looping. The special global function $() makes this possible. $() first looks for a method at the current location. If not found, it looks for a property at the current location. If not found, it checks the immediate parent location for a method, and if not found, a property. If neither are found, it checks the next-higher parent, etc. For example,
$( 'nodeBanner' )
will show the banner for the current node, if one is defined. If not, the function looks at the parent, then the parent's parent, and so on until it finds a node for which the property is defined, or it reaches the root of the site. As this example suggests, this works with built-in properties and methods as well as those you have defined yourself.
You can also call the function on a specific node, rather than the current location:
someplaceElse.$( 'someProperty' )
Built-in support for a hierarchical forum, custom properties and methods that are defined by reference, and the $() function all work together to unlock the power of Webcrossing in your scripting.
No comments:
Post a Comment