|
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 |
johdah Smarty n00b
Joined: 30 Oct 2014 Posts: 1
|
Posted: Thu Oct 30, 2014 10:53 pm Post subject: Widget inheritance |
|
|
I really love the inherit function in Smarty. But I can't get it to work perfectly with my design.
I have a master.tpl with a couple of blocks, one for the html head section for example.
I also have a page.tpl that extends master.tpl and add contents to the blocks.
So far no problems. But I also have a bunch of widgets, one for an image slider for example. Today I use the fetch function for image_slide.tpl and save the template in a variable. This var is then sent to page.tpl and its content is put in a block.
This work fine, but its not optimal. I want to be able to send data to different master blocks from the widget. My image-slider for example, needs to put data into a head block in master, but also in a css block and in a jquery block - besides the actual widget html block. If the widget was the child to master.tpl this would be simple, but it ain't. Page is the child and a couple of widgets is siblings to page.
Thanks for any help! |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Fri Nov 21, 2014 12:21 am Post subject: |
|
|
include, capture… Thre's multiple ways to do what you want.
I.e. I'm using this template to cache the output of included template in parent one.
Code: | {*
Smarty template
$Id: svgimage.tpl 204 2013-08-07 19:41:51Z anrdaemon $
*}
<object type="image/svg+xml" data="{$imageName|escape}"{if
$id} id="{$id|escape}"{/if}{if
$class} class="{$class|escape}"{/if}{if
$style} style="{$style|escape}"{/if}>{*
*}<param name="src" value="{$imageName|escape}"/>{if
$fallback}{include $fallbackTemplate inline}{/if}</object> |
|
|
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
|