use the contents of a TPL file in a PHP file

Hello everybody ,
To customize the detail view of a custom module, I created in the destination : \custom\modules<ModuleName> a folder named “views”, in which I put a file view.detail.php.

In this file,I redefined the method “display”, in which I called on a .tpl file (containing my personalization detail view)

Except that here I do not get the desired results, I get a few things that looks like this

  • The current result

  • The expected result is

Thank you to tell me how I can implement the TPL code in a PHP file,
Thank you

The view.detail.php class that you’re overriding grabs the template in the preDisplay method:

public function preDisplay()
 	    $metadataFile = $this->getMetaDataFile();
 	    $this->dv = new DetailView2();
 	    $this->dv->ss =&  $this->ss;
 	    $this->dv->setup($this->module, $this->bean, $metadataFile, get_custom_file_if_exists('include/DetailView/DetailView.tpl'));

You could try overriding this method and replacing ‘include/DetailView/DetailView.tpl’ with the tpl file you wish to use.

Hope this helps,

1 Like

thank you for your reply,
I tried what you said, but it does not work for me.
The file contents are as follows:

thank you very much it works, now there had just a small error in the code, at the 10 th row, there was a ‘&’ more

I have another question for you, concerning the recuperation of data via the TPL file.
Since the initial detail view is,

as the types of relationships are one to many
So I want to retrieve all the information in the detail view