views:

295

answers:

4

I have been asked to include some html snippet in this php/smarty page. It's basically a sales agreement at the end of an overview page before you pay.

What is the code to include static html into my php/smarty template?

Thanks...

+1  A: 

Do you mean include a file containing static HTML?

{include file="htmlfile.html"}

edit

As the file is just HTML, it might be better to use {fetch}, e.g.

{fetch file="path/to/html/file.html"}

For local files, either a full system file path must be given, or a path relative to the executed php script.

Tom Haigh
That's what I meant. But it returns this: `Warning: Smarty error: unable to read resource: "custom:betalingsvilkar.html" in /home/euroworkerno/www/library/smarty/libs/Smarty.php on line 1095`
Kyle Sevenoaks
`function trigger_error($error_msg, $error_type = E_USER_WARNING) { trigger_error("Smarty error: $error_msg", $error_type); }` and that's the line 1095.
Kyle Sevenoaks
+1  A: 

If you are trying to include some code containing javascript or similar, you can use {literal}{/literal} tags to inlude a file you can use {include file="htmlfile.html"} as Tom said.

Sinan
+1  A: 

Before you display the template, in the PHP file try this:

$smarty->assign('Sectionfile','section-name.html'); $smarty->display('template.tpl');

in the template itself:

{include file="html_dir/$Sectionfile"}

nik
Fatal error: Call to a member function assign() on a non-object in /home/euroworkerno/www/application/controller/CheckoutController.php on line 1354
Kyle Sevenoaks
That was returned when I added `$smarty->assign('Sectionfile','betalingsvilkar.html'); $smarty->display('completeOverview.tpl');`- My php/smarty sucks.
Kyle Sevenoaks
+1  A: 

Like any other templates, smarty files are HTML files itself. you can just paste your HTML into smarty template.

Col. Shrapnel
Yes, this was my first solution to what needs to be done, in my opion too, the best, seeing as this file is only included in one page, yet my boss is adamant about having it as an include.
Kyle Sevenoaks