Object BasicsAll TurboPhp objects are extensions of the TTpObj class. The TTpObj class exposes a number of useful fields and methods. Here are some of the useful fields in all TTpObj objects. var $App; // Refers to the TTpApp object that owns this TTpObj var $Name; // Object's name as specified in the tpname markup var $Elt; // The element from the object markup (e.g. div or input) var $Attributes; // Array of HTML attributes var $Style; // String containing the value of the style attribute var $Content; // Text between the start and end tags var $EndTag; // The end tag for the object (can be empty) var $Hidden; // True if the object should not be output to HTML var $OnGenerate; // Function to be called when the Generate event is fired The Attributes associative array initially contains name/value pairs parsed from the HTML markup (special TurboPhp attributes are automatically removed). The values can be accessed or modified like so: $obj->Attributes['width'] = 48; unset($obj->Attributes['bgcolor']); The Style string contains the complete value of the style attribute. Instead of modifying this field directly, individual style values should be modified with the Stylize function. $obj->Stylize('background-color', 'blue'); $obj->Stylize('font-family', ''); In general, fields of a TurboPhp object can be specified in markup using an attribute corresponding to the field prefixed with tp. For example, the attribute tpongenerate, as shown above, specifies a value for the OnGenerate field, and tphidden can be used to set the Hidden field. |