Copied to clipboard

Flag this post as spam?

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


  • Martin 278 posts 662 karma points
    Dec 09, 2014 @ 11:03
    Martin
    1

    7.2 Grid Layout - Custom Grid

    Hi, I'm playing around with the new 7.2 starter kit and really like the grid layout.

    I'd like to use an alternative grid to bootstrap and can see how to implement it from the starter kit. I'm getting a little confused though with the partial view (I'm one of those designer types).

    I'm using a grid system that uses text value rather than a numerical value for the column count.

    Is there a simple way to change [email protected] & [email protected] into a string value?

    Thanks

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 09, 2014 @ 11:31
    Jan Skovgaard
    0

    Hi Martin

    You should be able to change it - But unfortunately I don't have 7.2 open in front of me currently. However I think you can benefit from reading this documentation here http://our.umbraco.org/Documentation/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors-v7/Grid-Layout-Best-Practices and here http://our.umbraco.org/documentation/using-umbraco/backoffice-overview/property-editors/built-in-property-editors-v7/grid-layout

    Hope this helps :)

    /Jan

  • Niels Hartvig 1951 posts 2391 karma points c-trib
    Dec 09, 2014 @ 12:02
    Niels Hartvig
    0

    That would require a little bit of "scary" :) code as you'd need to make a little helper method that converts the integer value on the column to a text value, similar to this: http://stackoverflow.com/questions/2729752/converting-numbers-in-to-words-c-sharp

  • Martin 278 posts 662 karma points
    Dec 09, 2014 @ 15:32
    Martin
    0

    Thanks guys, scary code indeed.

    I've got a helper for converting integer into text, but i'm struggling to get the grid count inside @numberWords().

    @helper renderRow(dynamic row, bool singleColumn)
    {
        <div @RenderElementAttributes(row)>
            @Umbraco.If(singleColumn, "<div class='container'>")
            <div class="row clearfix">
                @foreach (var area in row.areas)
                {
                    <div class="[email protected] column @numberWords() ">
                        <div @RenderElementAttributes(area)>
                            @foreach (var control in area.controls)
                            {
                                if (control != null && control.editor != null && control.editor.view != null)
                                {
                                    <text>@Html.Partial("grid/editors/base", (object)control)</text>
                                }
                            }
    
                        </div>
                    </div>}
            </div>
            @Umbraco.If(singleColumn, "</div>")
        </div>
    }
    
    @helper numberWords(int numbers)
    {
        if (numbers == 0){
            <text>zero-columns</text>
        }
        if (numbers == 1){
            <text>one-column</text>
        }
        if (numbers == 2){
            <text>two-columns</text>
        }
        if (numbers == 3){
            <text>three-columns</text>
        }
        if (numbers == 4){
            <text>four-columns</text>
        }   
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft