Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Smarty and TinyMVC - One main template for all controllers

 
Post new topic   Reply to topic    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: 7365
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: 1385

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:   
Post new topic   Reply to topic    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