Saltar para o Conteúdo principal

Include custom HTML files or execute custom PHP files in templates - Knowledgebase / Developer & Reporting / Portal Customization - Deskpro Support

Include custom HTML files or execute custom PHP files in templates

Lista de autores

These options increase the power of the template system.

To use these options you need to enable a special option. Add this line to your config.php file:

$DP_CONFIG['enable_include_file'] = true;

 

Including a file in a template

Use the include_file template function to include a file:

<div class="page">
{{ include_file('/path/to/file.html') }}
</div>

 

The file will be included as-is (i.e., the contents are not filtered or executed in any way).

 

Including and executing PHP in a template

Use the include_php_file template function to include a PHP file:

<div class="page">
{{ include_php_file('/path/to/file.php') }}
</div>

 

The file will be PHP include()'ed into the template. This means the file will be executed as PHP and the contents captured and inserted into the template.

You can pass template variables into the local scope by passing a second parameter:

<div class="page">
{{ include_php_file('/path/to/file.php', {user_email: app.user.primary_email_address}) }}
</div>

// In file.php
echo "Hello, $user_email\n";

Útil Inútil

38 de 82 pessoas acharam esta Página útil

Adicionar um comentário

Inicie sessão ou registe-se para enviar um comentário.

Precisa de recordar a palavra-passe?