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 not loading block content in sub include

 
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 -> General
View previous topic :: View next topic  
Author Message
PierceMcGeough
Smarty n00b


Joined: 10 Jan 2014
Posts: 3

PostPosted: Fri Feb 27, 2015 2:33 pm    Post subject: Smarty not loading block content in sub include Reply with quote

Working with smarty and I am trying to reduce reused code across multiple layout pages I use. The below works as expected... doctype gets included, meta tags get included, header_scripts takes in the scripts in the page that extends layout etc.... but {include file=$layout.box_title} has both html and another block in it. It catches the html and parses it but wont add the block content. It will pick up default code in the block but not the given from the used page. It works ok if I copy the included file code and place it where the include line is.

I am wondering if this is a bug, a load order issue or it what I am trying is even possible.

Code:
layout.tpl
====================================================
{include file=$tpls.doctype}
<head>
    {include file=$tpls.meta}
    <link rel="stylesheet" href="{$assets_url}build/css/base.min.css">
    {block name=header_scripts}{/block}
    {include file=$tpls.flaty_showhouse_css}
</head>
<body>
    {include file=$tpls.navbar}

    <div class="container" id="main-container">
        {include file=$tpls.sidebar}

        <div id="main-content">
            <div class="row">
                <div class="col-lg-12">

                    <div class="box">

                        {include file=$layout.box_title}

                        <div class="box-content clearfix showhouse-border">



block_title.tpl
===================================
<div class="box-title showhouse-colour-dark">
    <h3>{block name=box_title}{/block}</h3>
    <div class="box-tool">
        <a class="entity_button"><i class="fa fa-bars"></i></a>
    </div>
</div>
Back to top
View user's profile Send private message Send e-mail
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sat Feb 28, 2015 11:45 am    Post subject: Reply with quote

Currently template inheritance is a compile time process where the code of parent {block} tags is preplaced with the code of child {block} tags. This does work with
parent templates which are included by the extends resource or {extends} tag.

It does not work with {block} tags of templates included by {include}.

This restriction will be removed in the upcomming 3.1.22 release (I currenty have not yet a release date)
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 -> General 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