Page 1 of 1

[SOLVED] How to extend templates?

Posted: Wed Oct 21, 2015 5:03 pm
by nervino
Hi, I would nest a template in the Smarty's {block} tag.

I have a default template, called "Automotive default", with an empty footer block.

inside template "Automotive default" I put:

Code: Select all

{block name='footer'}{/block}
I also have made a template called "footer inner page" with some HTML inside.

Hence, I made a page template called "Inner page" that should extend "Automotive default", inserting the template "footer inner page" inside the "footer" block .

template: "Inner page"

Code: Select all

{extends file='template:Automotive default'}
{block name=footer}
How do I insert the template "footer inner page" here?

Code: Select all

{/block}
Is this a right way to use the new template's management of cmsms 2.x?


Thank you

Re: How to extend templates?

Posted: Wed Oct 21, 2015 5:28 pm
by Jo Morg
You are confusing different terms: extending VS including.
To extend a template you need to understand inheritance. Including a template is the closest there is to the old use of Global Content Blocks. And for that you don't need blocks, you just include another existing template by using {include file='cms_template:footer inner page'}. If you really want to use template inheritance you should start by reading the Smarty docs on the Smarty site. Inheritance is closely related with objects inheritance in programming, in that a template that extends another, inherits all the parents properties, and adds or overrides some of it's parents properties, keeping a designer from re-writing the same basic template over and over again...

http://www.smarty.net/docs/en/advanced. ... itance.tpl

http://docs.cmsmadesimple.org/introducing-cmsms-2-0

BTW template inheritance and inclusion have always been there, are Smarty features. We just optimized the way CMSMS uses these features.

Re: How to extend templates?

Posted: Wed Oct 21, 2015 6:24 pm
by nervino
Jo, thank you very much for your explanation.

My goal was to have a default template with an empty footer, then have other templates that extend the default one overriding the {block name='footer'}{/block} with the appropriate footer (this is a semplification as the templates are more complex).

Now it works.

By the way, is there any difference between
{include file='cms_template:footer inner page'}
and
{include file='template:footer inner page'}

Re: How to extend templates?

Posted: Wed Oct 21, 2015 11:32 pm
by Jo Morg
nervino wrote:By the way, is there any difference between
{include file='cms_template:footer inner page'}
and
{include file='template:footer inner page'}
Yes: both are CMSMS template resources registered in Smarty, although the template has been deprecated and will eventually be removed.