Feather Sub Templates/Layouts

Posted by Community Admin on 05-Aug-2018 11:23

Feather Sub Templates/Layouts

All Replies

Posted by Community Admin on 15-Oct-2014 00:00

Hi,

 

I'm aware that page templates can be created using cshtml and can contain a custom Placeholder call (SfPlaceholder). However, I cannot add multiple placeholders to a page, and also don't understand how sub templates containing layout html can be created to be included in the page template.

 Is there any documentation available on this? I'm presuming these basic features are possible?

Posted by Community Admin on 15-Oct-2014 00:00

Hi Daniel, 

Feather comes with a set of build in packages like Bootstrap, Foundation and SemanticUI that provide layouts out of the box:

https://github.com/Sitefinity/feather-packages/tree/master/Bootstrap

When this layouts are added to the folder SitefinityWebApp\ResourcePackages we automatically generate for you a Sitefinity template based on the layout file(for the Bootstrap layout it is named “Bootsrap.default”). This page templates are editable and you can customize them by dragging controls to them.

In Feather we provide set of grid widgets that could be used to order the controls over your template. The grid widgets are available inside the “Bootstrap grid widgets”. You can find more details about this grid widgets here.

You can create your own grid widgets like described in this article: 

For additional reference check the attached screenshot with sample bootstrap based template.


Regards,
Elena Ganeva
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 15-Oct-2014 00:00

Brilliant, that was what I was looking for - thank you.

 Some further questions...

 Can Widgets be embedded with code directly into the layouts? To save content editors from dragging a 'header widget' onto the page, I'd like it always to be there.

Can widgets be restricted to certain columns, or quantities within these columns?

Posted by Community Admin on 16-Oct-2014 00:00

Hello Daniel, 

You can add a control to your pages in code like this:

void AddControlToPage()
        
            PageManager pageManager = PageManager.GetManager();
            var pageNode = pageManager.GetPageNodes().Where(p => p.Title == "MyTitle").FirstOrDefault();
            if (pageNode != null)
            
                var pageDataId = pageNode.PageId;
                var page = pageManager.EditPage(pageDataId, CultureInfo.CurrentUICulture);
 
                //add web forms widget
                var blogsWidget = new Telerik.Sitefinity.Modules.Blogs.Web.UI.BlogPostView();
                var blogsWidgetControl = pageManager.CreateControl<PageDraftControl>(blogsWidget, "Contentplaceholder1_ctl01_C_C004_Col01");
                blogsWidgetControl.Caption = "BlogPostWidget";
                pageManager.SetControlDefaultPermissions(blogsWidgetControl);
                page.Controls.Add(blogsWidgetControl);
                //end add web forms widget
 
                //add MVC widget
                var mvcWidget = new Telerik.Sitefinity.Mvc.Proxy.MvcControllerProxy();
                mvcWidget.ControllerName = "ContentBlock.Mvc.Controllers.ContentBlockController";
                mvcWidget.Settings = new Telerik.Sitefinity.Mvc.Proxy.ControllerSettings(new ContentBlockController()
                
                );
 
                var draftControlDefault = pageManager.CreateControl<PageDraftControl>(mvcWidget, "Body");
                draftControlDefault.Caption = "Content block";
                pageManager.SetControlDefaultPermissions(draftControlDefault);
                page.Controls.Add(draftControlDefault);
                //end add MVC widget
 
                //publishes draft page
                pageManager.PublishPageDraft(page, CultureInfo.CurrentUICulture);
                pageManager.SaveChanges();
            
        

This sample code displays how you can add web forms widget or MVC widget to a page. If your page is based on pure MVC template (like Bootstrap) you are allowed to add MVC widgets only to it.

In this snippet you should change the type of the control that you are adding to MvcProxyWidget and the placeholder where you place it. You can check the id of the placeholder in your browser tools by inspecting the gird widget output (see the attached screenshot). The name of the placeholder is available the part of the id starting with “Contentplaceholder”of the sf_colsIn element.

Regards,
Elena Ganeva
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 17-Oct-2014 00:00

Where would this code go? I would want the widget to already be on the page at the time of it's creation.

 Also, any ideas on limiting place holders to certain numbers or types of widget?

Posted by Community Admin on 21-Oct-2014 00:00

Hi Daniel,
Thank you for getting back to us.

1. This code could be in the global.asax for your project when the site is initialized. Then you could check if the widget is not already added to a page in order to prevent duplication.

2. What are you trying to achieve by limiting the number of placeholders in the page?

Regards,
Yavor Slavchev
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed