Using templates inside templates?

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
Squire4Hire
Forum Members
Forum Members
Posts: 43
Joined: Wed Dec 09, 2015 11:16 pm

Using templates inside templates?

Post by Squire4Hire »

I'm working in 2.x and having a hard time figuring out whether or not this is even possible.

Let's say you have a basic framework as a template - header with navigation, main content, and footer. This is pretty universal when it comes to website content structure so I'd like to be able to use it throughout the site.

What I'm trying to do though is to inject a "templated" piece of code into that structure on one of the Content pages so that the user can make changes to the content within that template block.

For example: Using the structure stated above as the default template design, I want to create two pages - a Home Page and a Content Page.
Inside the home page I want to add a slider at the top. I'd like the user to be able to define the images and the headers that apply to that slider. Inside the content page, I want to have a static image at the top. And I'd like the user to be able to define that image. But I want the templates to be completely separate so that the user enters content into the Home Page, Content Page, and Slider independently.

I assumed that I would be able to create a Core::Page template with navigation, content, footer then create a Core::Generic with the applicable slider content blocks. That way when I create the Home Page, I can add an {include file='cms_template:My Slider'} in order to call that chunk of code.

The problem with creating a Core::Generic is that I can't select it as a Template Type which means the user can't modify the content blocks. And if I choose to make My Slider as a Core::Page, the elements are then added to the Default template structure or there's a conflict of either having no default content block or having a duplicate default content block.

Is there no way to create a separation of concerns?
I suppose the only other way to do this would be to create different templates with the same elements (header, navigation, footer) in each?
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: Using templates inside templates?

Post by Rolf »

You tried the Template Inheritance method?
http://www.cmscanbesimple.org/blog/the- ... gn-manager
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
Squire4Hire
Forum Members
Forum Members
Posts: 43
Joined: Wed Dec 09, 2015 11:16 pm

Re: Using templates inside templates?

Post by Squire4Hire »

Thanks Rolf. That's exactly what I'm looking for.
Locked

Return to “CMSMS Core”