Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Template in Template (.tpl) smarty

Tags:

php

smarty

hey, Since a few weeks I'm try to program a PHP-Application with the smarty template solution. Now a easy question for all professionals: How can I get a Template in a Template ? One example: index.php (page.tpl) include my login.php (login.tpl)

In the smarty documentation I have found this function: {include file="$tpl_name.tpl"}

But where is my login.php controller ? When this function include the login.tpl file, I have only HTML code or ?

Can someone explain me this or give me a sample / tutorial ?

Sorry for my bad english

best regards

like image 423
Patrik Avatar asked Mar 10 '26 00:03

Patrik


1 Answers

That code is exactly what you want. It will let you include another smarty template from within a template.

<html>
<head>
  <title>{$title}</title>
</head>
<body>
{include file='login.tpl'}

All variables available to the original template, are available to the template you just included.

Im not sure what you're saying about only having HTML code, maybe you're wanting this function instead:

{include_php file='/path/to/login.php'}
like image 153
profitphp Avatar answered Mar 12 '26 16:03

profitphp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!