WebTemplate Nodes are accessed and manipulated in PHP through Objects. To get the Object for a node, the WebTemplate::getNode() function is called. For example, to get the object for the admin user:
$adminUser = $GLOBALS["WT"]->getNode("/Contacts/__admin");
If a PHP class has been registered to the Node Type of the node, then an object of that Class will be returned, otherwise an object of the class WTNode will be returned.
A class registered to a Node Type must extend either WTNode or a class which extends WTNode.
Each node can be identified by a Path (eg "/Contacts/__admin"), the guid of the node (eg 12), or a user defined key for the node (eg "admin user")
// getting a node by path
$admin = $GLOBALS["WT"]->getNode("/Contacts/__admin")
// getting a node by guid
$admin = $GLOBALS["WT"]->getNode(12);
// getting a node by key
$admin = $GLOBALS["WT"]->getNode("#admin user");
WebTemplate::getNode() is defined in wt.php
WebTemplate::getNode() will first check if the node defined by the parameters has been accessed before in the same request. If so, it will return the node from the cache.
If the node has not been accessed and either a key or a path has been passed in, WebTemplate::getNode will translate the key or path into a guid.
WebTemplate::getNode will then use the following sql to return the node type and wtNode record for the node with the corresponding guid:
SELECT
wtNode.*,
wtType.`Type Name`
FROM
wtNode
LEFT JOIN
wtType
ON
wtNode.__typeGuid = wtType.__guid
WHERE
wtNode.__deleted = 0
AND wtNode.__guid = {guid}
if(array_key_exists($typeName, $this->m_nodeRegistry)) {
$node = new $this->m_nodeRegistry[$typeName]($guid);
} else {
$node = new WTNode($guid);
}