T
T
theptashyts2015-04-05 16:23:22
PHP
theptashyts, 2015-04-05 16:23:22

How to create template using .tpl .php formats?

How to register variables in a .php file and display them in .tpl, how to link these files together?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
A
Alexey Yaroshevich, 2015-04-05
@qfox

It all depends on the template engine that suits you.
twig.sensiolabs.org
https://github.com/smarty-php/smarty/
https://github.com/alexeyrybak/blitz ( habrahabr.ru/post/18695 )
habrahabr.ru/post/128645
Or whatever something like xslt:
https://github.com/bem/bh-php
If you need a more precise answer - decide on the question ;-)

G
Gluck Virtualen, 2015-04-06
@gluck59

page.php

$name = 'вася';
$email = '[email protected]';
    $smarty->assign(array(
  'name' => $name, 
  'email' => $email
    ));

    return $this->display(__FILE__, 'page.tpl');

page.tpl
<p>
Привет, {$name}!
</p>
<p>
Теперь твой емейл — {$email}.
</p>

V
Vladimir, 2015-04-05
@azrail_dev

google on smarty, there is just php and tpl

V
VolodyaHome, 2015-04-05
@VolodyaHome

Learn the concept of mvc, it is well described how to transfer data from the controller to the view.

I
infastin, 2015-04-05
@infastin

Use templating engines like:
- Smarty
- Twig

6
65536, 2015-04-05
@65536

anything but smart

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question