Neidio i'r brif gynnwys

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

Rhestr o awduron

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";

Defnyddiol Annefnyddiol

Roedd 38 o 82 o bobl yn teimlo bod y dudalen hon yn ddefnyddiol

Ychwanegu sylw

Mewngofnodwch neu cofrestrwch i gyflwyno sylw.

Angen atgofiad am eich cyfrinair?