Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Smarty and TinyMVC - One main template for all controllers

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Frameworks
View previous topic :: View next topic  
Author Message
danny36
Smarty Rookie


Joined: 14 Jul 2004
Posts: 27
Location: Italy - Arezzo (Tuscany)

PostPosted: Thu Apr 05, 2018 10:21 am    Post subject: Smarty and TinyMVC - One main template for all controllers Reply with quote

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
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Apr 18, 2018 1:06 am    Post subject: Reply with quote

Sure, add Smarty and use template inheritance. The docs show an example.
Back to top
View user's profile Send private message Visit poster's website
danny36
Smarty Rookie


Joined: 14 Jul 2004
Posts: 27
Location: Italy - Arezzo (Tuscany)

PostPosted: Wed Apr 18, 2018 7:25 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed Apr 18, 2018 11:06 pm    Post subject: Reply with quote

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
View user's profile Send private message
crownclown67
Smarty Rookie


Joined: 03 May 2018
Posts: 12

PostPosted: Thu May 03, 2018 6:50 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Frameworks All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP