Gå til hovedindhold

Include custom HTML files or execute custom PHP files in templates - Videnbase / 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";

Hjælpsom Unyttig information

38 af 82 personer fandt denne side nyttig

Tilføj en kommentar

Log ind, eller opret dig for at skrive en kommentar.

Har du brug for en påmindelse om adgangskode?