how to {extends} file into extended file?

107 views Asked by At

I'm a beginner at smarty and having difficulty working out a standard method to include frames and message boxes into my pages.

Here is the code I have and how I want it to function. I've been trying different methods for the last three days and ending nowhere:

index.php

$smarty->display('mypage.tpl');

mypage.tpl

{extends 'main_frame.tpl'}

{block 'title'}This is an example{/block}

{block 'body'}
  <p>This page is built with smarty</p>

  {extends 'message_box.tpl'}
  {block 'body'}
    <h1>Smarty is fun</h1>
  {/block}

{/block}

main_frame.tpl

<html>
  <head>
    <title>{block 'title'}{/block}{/title}
  </head>
  <body>{block 'body'}{/block}</body>
</html>

message_box.tpl

<div style='boarder: thin solid #f0f0f0;'>
  {block 'body'}{/block}
</div>

The rendered code should be something like this:

<html>
  <head>
    <title>This is an example{/title}
  </head>
  <body>
    <p>This page is built with smarty</p>
    <div style='boarder: thin solid #f0f0f0;'>
      <h1>Smarty is fun</h1>
    </div>
  </body>
</html>
0

There are 0 answers