International Sites:





/ PORTUNITY.INFO /


Deriving Portalsuite Objects

You can derive all documented object of the „Portalsuite Objects“ library in own classes and then again build instances thereof.

In deriving you have got the possibility, as usual, to overwrite and therewith modify functions. We would like to show this with a little example with the class PTemplate:

Template excerpt:



<?

Class MyOwnTemplate extends PTemplate

{

var $MyTemplateValue;



function MyOwnTemplate ()

{

$this->MyTemplateValue = "";

parent::PTemplate ();

}

function Field ($Field)

{

if ($Field=="TemplateValue")

return ($this->MyTemplateValue);

}

function WriteField ($Field,$Content)

{

if ($Field=="TemplateValue")

$this->MyTemplateValue = $Content;

}

function Valid ()

{

return (1);

}

}



$ATestTemplate = new MyOwnTemplate;

$ATestTemplate->WriteField ($Field,"

<?

echo (\"This is a test template ;-)\");

?>

");



$ATestTemplate->Output ();



?>




In this example a new class named„MyOwnTemplate“ is derived from „PTemplate“. Of course this class inherits all properties and functions of the „Portalsuite Objects“ class „PTemplate“. But some of the functions are overwritten, by doing so we change the inherited behaviour. We overwrite the „Field“ and „WriteField“ functions and modify the field „TemplateValue“ corresponding with a self-defined local object variable. Through this we generated a class which is run capable independent from the Portalsuite data base and does not represent any template data records there anymore. Also the Valid function has been overwritten for this reason: Since the new class does not represent data sets of the data base anymore, instanced objects are quasi always valid.
In case of instancing we don’t have to pass a template name to the constructor anymore, nevertheless we can use the WriteField for writing in our internal object variable and use the output function, which has been taken over, to output and interpret the „template“.


Continue to recommend this article:

Your Name:

Your eMail-Adress:

eMail of Recipient:

Additional text:







Direct links to the new Portalsuite 2002:

- Productinfos
- Download

- Support overview
- Support forum