Hopp over til hovedinnhold

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

Include custom HTML files or execute custom PHP files in templates

Forfatterliste

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 hjelp Ikke til hjelp

38 av 82 personer syntes denne siden var til hjelp

Ny kommentar

Logg på for å registrere eller sende inn en kommentar.

Trenger du en påminnelse om passord? '