Resource Files

From HTML5 Builder
Jump to: navigation, search

Resource files are XML files surrounded by PHP tags (<?php ?>), with .xml.php extension. They are used to store data to setup top-level containers and all their child components upon script execution, letting you separate that initialization data from the logic of your application.

Each component is represented by an object element, which might have three attributes:

  • class. The name of the class defining the component, that is, the type of component.
  • baseclass. The base class from which the component class is a child. This is normally used when you subclass a component, common with top-level containers (for example, class MyPage extends Page { /* … */ } equals to <object class="MyPage" baseclass="Page"><!-- … --></object>).
  • name. The Name of the component.

Inside an object element, each property is represented by a property element. Each property as a name attribute, which is assigned the name of the property, and the content of the property element is the actual initialization value of the property. For example: <property name="Caption">This is the caption</property> would be the same as $ComponentName->Caption = "This is the caption";.

Note: object elements representing a container might conatin other object elements.

Any event will be treated as a property, containing the name of the event handler to be executed when the event is triggered. For example: <property name="OnBeforeShow">updateLabelContent</property>.


You can load the configuration of a component from a resource file calling the loadResource() method on the component and providing the path to the resource file (with its .xml.php extension reduced to .php) as the first and only parameter. If you call this method on a container (for example, a Page), the configuration for the container will be loaded, as well as the configuration for all the components it owns.

Tip: __FILE__ is a PHP magic constant, which is replaced by the full path and filename of the file where it is called.
Personal tools