Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8515883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:16:06+00:00 2026-06-11T05:16:06+00:00

I am attempting to create a template using Smarty for php. I would like

  • 0

I am attempting to create a template using Smarty for php. I would like the template to be reusable so I inheriting it and substituting values using blocks. This works fine except when I need to access these block values in sub-templates. I am calling these sub-templates using smarty’s {include} function.

Example:

Template-Parent (template.tpl):

<html>
     <head>
         {include file=sub_template.tpl}
     </head>

     <body>
         {block name=title}No Title Provided{/block}
     </body>
</html>

Sub-Template (sub_template.tpl)

     <title>{block name=title}No Title Provided{/block}</title>

Template-Child (template_child.tpl)

     {extends file="template.tpl"}
     {block name=title}My Website!{/block}

When I view the site, the output is:

<html>
     <head>
         <title>No Title Provided</title>
     </head>

     <body>
         My Website!
     </body>
</html>

After doing some reaserch I did see a note on smarty’s website about enclosing {include} functions in dummy {block} tags but have had varied levels of success getting this to work.

Note:
If you have a subtemplate which is included with {include} and it
contains {block} areas it works only if the {include} itself is
called from within a surrounding {block}. In the final parent
template you may need a dummy {block} for it.(http://www.smarty.net/docs/en/advanced.features.template.inheritance.tpl)

Due to this, I have tried:

<html>
     <head>
         {block name=dummy}{include file=sub_template.tpl}{/block}
     </head>

     <body>
         {block name=title}No Title Provided{/block}
     </body>
</html>

This seems to work until I make any change to sub-template. As soon as a change to the sub-template is made, it once again stops responding to the block values set in the child.

Have I misunderstood what the notice was referring to about placing the {include} in dummy block tags or is this a bug with smarty? I am not currently using caching but my other thought was that maybe this is a sub-template caching problem.

Any insight would be greatly appreciated, thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:16:07+00:00Added an answer on June 11, 2026 at 5:16 am

    It is true that these templates are compiled and cached into the templates directory. This is why clearing the templates directory temporarily fixed the issue. The template caching is different than the explicit caching that smarty also supports. I have found that the template caching can be overridden with:

    $smarty->compile_check = true;
    $smarty->force_compile = true;
    

    This allows changes to the template to be made with out needing to delete the cache after change while in development.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to create a php template that includes object oriented code. Here's a
I attempting to create custom tabs using this . But when I try to
I'm attempting to create C#-like multicast delegates and events using features from TR1. Or
I am attempting to create a template AutoClass that create an arbitrary class with
I'm attempting to create a table for monitoring purposes using the following script: $w3wppriv
I am attempting to create a Tab Control Style that basically looks like buttons
I am attempting to create a struts2 component using freemarker. I created an ftl
I'm attempting to create a template system where an uploaded jpg is then placed
Using NPOI and attempting to follow a tutorial here: http://www.zachhunter.com/2010/05/npoi-excel-template/ , I'm coming across
I'm attempting to create a tag inside the head of my site using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.