Page 1 of 1

Core::Generic templates - why and how?

Posted: Mon Apr 11, 2016 5:53 pm
by spcherub
I'm trying to understand the purpose of the Core::Generic templates in CMS2. I've read the documentation that refers to the existence of this type of template, but have not found any information about why, how and when they should be used. I saw a reference that said they could be used to replace GCBs, but the only example I saw of implementing GCBs in CMS2 was using content blocks on a regular page template.

Please point me at any references, documentation and examples so I can understand and start to use this new feature.

TIA,
Sanjay

Re: Core::Generic templates - why and how?

Posted: Mon Apr 11, 2016 6:42 pm
by Rolf
The old tag still works:

Code: Select all

{global_content name='foo'}
The new tag is

Code: Select all

{include file='cms_template:foo'}
But with the new way of templating, you really don't need to use GCB's!
Read: http://www.cmscanbesimple.org/blog/the- ... gn-manager

Re: Core::Generic templates - why and how?

Posted: Mon Apr 11, 2016 6:58 pm
by spcherub
@Rolf - thanks for the response. My question was more about the Generic template itself and the GCB issue was a way to put some context around it.

In your example, it looks like you are include a copy of the template itself. Does this mean that the Core::Generic template is not actually intended to be instantiated into a page or come other content instance? So it is only used to contain base template instances that are inherited by other ones?

Re: Core::Generic templates - why and how?

Posted: Mon Apr 11, 2016 7:15 pm
by calguy1000
As mentioned in the documentation and during release announcements

template are templates. generic templates are treated exactly the same as page templates or Navigator templates, or News templates. The type field is used for filtering at the application level. (i.e: to show you only page templates when selecting a template for a page). 2.x does not any longer differentiate types of templates. The type field is also used when modules uninstall so that they can delete templates that are related to that module. The exception being that modules using the old module-template api are still supported.

There is absolutely nothing stopping you from using a generic template for a news summery template, or news detail template or Navigator template, or page template. Except for the fact people like to have their template lists shorter and pre-filtered for them. Additionally, there is nothing stopping you from calling {include file='cms_template:my-news-summary'} in your page template, where that template is flagged as being associated with the news module.

{News summarytemplate=foo} where "foo" has the type flag of Core::generic will work.

And now there is no option for GCB's to have wysiwygs attached to them.

Re: Core::Generic templates - why and how?

Posted: Mon Apr 11, 2016 7:21 pm
by calguy1000
Follow up.

The root of the story is:

We've unified the template functionality. Instead of separate API's for page templates, generic templates (used to be global content blocks) and module templates. there's now one single API. The 'type' thing is just a field in the database to use for filtering at the application level.

[edit: corrected to fix blind typing]

Re: Core::Generic templates - why and how?

Posted: Tue Apr 12, 2016 2:10 am
by spcherub
@calguy - thanks for the detailed explanation. The unified approach to templates certainly makes sense now.

One follow up question - I'm assuming that while the Generic template can be used for News, Navigation etc., it cannot be used on its own to create a Page, right?

Sanjay

Re: Core::Generic templates - why and how?

Posted: Tue Apr 12, 2016 11:14 am
by velden
Yes, it can be used to create a page template. However:

1. note it doesn't check for the existence of the default content block {content}
2. to be able to actually select those templates when creating a new page, you should change one setting:
Site Admin -> Settings - Content Manager -> Template list mode: an option which allows NOT only page template.