|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Stardog Smarty n00b
Joined: 03 Apr 2012 Posts: 2
|
Posted: Tue Apr 03, 2012 7:56 pm Post subject: Simple Block usage help |
|
|
I'm trying to insert a simple piece of code into a child template, so I can just change that one file, and re-use it elsewhere. I searched, but didn't find anything.
I have a "mainlayout", and a "firstpage" layout that extends "mainlayout".
mainlayout has "{block name="content"}{/block}" that inserts whatever's in the firstpage.
But I want to insert an ad into "firstpage". If I put "{block name="ad"}{/block}", and create a "ad" template that extends "firstpage" it won't work, nor extending from "mainlayout".
I tried {include file...} but it doesn't work.
Example:
mainlayout.thtml
Code: | {block name="content"}This takes what's inside the content block of frontpage. Works fine.{/block} |
frontpage.thtml
Code: | {extends file="mainlayout.thtml"}
{block name="content"}{/block}
{block name="ad"}{/block} |
ad.thtml
Code: | {extends file="frontpage.thtml"}
{block name="ad"}Ads go here.{/block} |
|
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Apr 03, 2012 8:23 pm Post subject: |
|
|
Only {block} defined in the parent template mainlayout.thtml get extended by child template blocks. |
|
Back to top |
|
Stardog Smarty n00b
Joined: 03 Apr 2012 Posts: 2
|
Posted: Tue Apr 03, 2012 9:18 pm Post subject: |
|
|
Ahh the include actually worked anyway. I had left a smarty tag in the file I wanted to include by mistake.
Thanks! |
|
Back to top |
|
|
|
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
|