+1-888-365-2779
Try Now
More in this section

Forums / Project Feather / Feather Sub Templates/Layouts

Feather Sub Templates/Layouts

6 posts, 0 answered
  1. Daniel
    Daniel avatar
    13 posts
    Registered:
    30 Jul 2014
    15 Oct 2014
    Link to this post

    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?

  2. Elena Ganeva
    Elena Ganeva avatar
    36 posts
    Registered:
    20 Jul 2016
    15 Oct 2014
    Link to this post

    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
     
  3. Daniel
    Daniel avatar
    13 posts
    Registered:
    30 Jul 2014
    15 Oct 2014
    Link to this post

    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?

  4. Elena Ganeva
    Elena Ganeva avatar
    36 posts
    Registered:
    20 Jul 2016
    16 Oct 2014
    Link to this post

    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
     
  5. Daniel
    Daniel avatar
    13 posts
    Registered:
    30 Jul 2014
    17 Oct 2014
    Link to this post

    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?

  6. Yavor Slavchev
    Yavor Slavchev avatar
    27 posts
    Registered:
    13 Sep 2016
    21 Oct 2014
    Link to this post
    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
     
6 posts, 0 answered