|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
danny36 Smarty Rookie
Joined: 14 Jul 2004 Posts: 27 Location: Italy - Arezzo (Tuscany)
|
Posted: Thu Apr 05, 2018 10:21 am Post subject: Smarty and TinyMVC - One main template for all controllers |
|
|
I try to build a basic project with smarty+tinymvc and I want to have a single index.tpl file where I put html, head and body tags then all controllers page have a specific tpl but I want to put the resulting template in a variable that can I assign to a index.tpl variabile.
It's possible? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Apr 18, 2018 1:06 am Post subject: |
|
|
Sure, add Smarty and use template inheritance. The docs show an example. |
|
Back to top |
|
danny36 Smarty Rookie
Joined: 14 Jul 2004 Posts: 27 Location: Italy - Arezzo (Tuscany)
|
Posted: Wed Apr 18, 2018 7:25 am Post subject: |
|
|
Hi mohrt, thank you for reply.
I have tried template inheritance but I don't like to put in all child templates the father extends tag.
It's not possible to assign a template variable from php with the result of compiled template of current view? |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Wed Apr 18, 2018 11:06 pm Post subject: |
|
|
Your PHP code should know nothing about your templates.
What you're asking for is an opposite of what templating engines are supposed to mean. |
|
Back to top |
|
crownclown67 Smarty Rookie
Joined: 03 May 2018 Posts: 12
|
Posted: Thu May 03, 2018 6:50 pm Post subject: |
|
|
this is how I use smarty, details of inheritance is in VIEW layer.
Code: |
{extends file="web/layout.tpl"}
{block name=title} Some cool name {/block}
{block name="content" }
<div class="">
Some content
</div>
{/block}
|
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|