Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ivan 15 posts 125 karma points
    Jan 25, 2017 @ 08:07
    Ivan
    0

    Newbie question for nesting layout options

    Hi all. Apologies if this was addressed before, but I couldn't find correct solution. I'm currently using Umbraco version 7.5.6. So far I have setup master template which "creates" header and footer and many other templates that use master template, and that works great. I have great control over content and it's pretty easy to create it with grid frontpage, textpage etc. Great addition, btw :). Anyway, I would like to know how do you setup your layouts and templates so that you can have following scenario. Header and footer are created in master template and are consistent throughout the site, as the should be. As shown in the following image

    enter image description here

    But I would like to create standard sidebar for different types of pages. For example, I'd like to have 2 documents types, lets say A and B. All pages type A should have one content in sidebar and pages type B should have another. Point of this is enable user to create content on a page with grid (2 column layout) but put all of his content in first column and have a sidebar that contains something else.

    How do i setup templates so this can be solved, Thanks in advance. Ivan

  • Tim Watts 90 posts 395 karma points
    Jan 25, 2017 @ 08:42
    Tim Watts
    0

    Hi Ivan,

    The solution depends on what your razor view is inheriting from, one of the following should hopefully work

    @if (UmbracoHelper.AssignedContentItem.DocumentTypeAlias == "PageTypeA") { ... }
    

    Or

    @if(Model.Content.DocumentTypeAlias == "PageTypeA") { ... }
    

    You can choose which mark-up or partial view to render for your sidebar.

    Tim

  • Ivan 15 posts 125 karma points
    Jan 25, 2017 @ 12:23
    Ivan
    0

    Thank you very much Tim for your fast reply. Unfortunately my question is more template oriented. Let me explain.

    I want child pages to have 2 column layout, for example news. News template now looks like:

    @{
        Layout = "Master.cshtml";
    }   @CurrentPage.GetGridHtml("newsgrid","fanoe")
    

    I want to setup news document type so it has 1 column layout maximum width, which will enable user to enter content. Such content should be shown in center content, in upper picture. But I would like to add in news template another column which would be sidebar and that would be predifened (view).

    As you noticed, I'm using fanoe starter kit and with that every grid content gets rendered as following.

    <div class="umb-grid">
                    <div class="grid-section">
                     <div >
                      <div class='container'>
                          <div class="row clearfix">
                             <div class="col-md-12 column">
                                <div >
    -- Content from grid that user entered --
    </div></div></div></div></div></div></div></div>
    

    Anyway, I planned to change news template in a way that I create 2 column layout with first column width 9 and second width 3.

    In first column i would like to put content from grid and in a second I'd like to put sidebar content. That would look something like this:

    <div class="umb-grid">
        <div class="grid-section">
                    <div class="container">
                        <div class="row clearfix">
                                    <div class="col-md-9 column">
                    //Content from a grid. 
                    </div>
                                    <div class="col-md-3 column">
                    //SiderBar content
                    </div>        
                </div>      
            </div>
             </div>
     </div>
    

    And the problem is that content created by grid (since its created i 1 column layout it takes up all of the page and I cannot get 9-3 ratio that I wanted. Is this the way its supposed to be done or is there another one? So, hope I made myself clear this time.

    Thanks in advance

  • Tim Watts 90 posts 395 karma points
    Jan 25, 2017 @ 13:11
    Tim Watts
    100

    Okay, I think I understand now. The grid doesn't shrink down to fit into a col-md-9.

    The grids are rendered using the Views\Partials\Grid\Bootstrap3.cshtml template. Your answer will most likely lie in changing this.

    If you get nowhere I'll try to have a look, but it might not be for a few days.

    Tim

  • Ivan 15 posts 125 karma points
    Jan 25, 2017 @ 13:21
    Ivan
    0

    I solved this few minutes ago by doing just that and it worked. Can't believe you suggested it too.

    Anyway, I copied fanoe rendering engine and made my own, just made sure that it renders every column as md 9.

    Still, sounds like strange way to solve this. This would be a good idea to implement. Create template via gui (1, 2 column layout) and that is then written in template file.

    Thanks once again, bless ya.

Please Sign in or register to post replies

Write your reply to:

Draft