Giter Club home page Giter Club logo

skybrud.umbraco.griddata.leblender's Introduction

Skybrud.Umbraco.GridData.LeBlender

Skybrud.Umbraco.GridData.LeBlender is an addon for Skybrud.Umbraco.GridData which adds support for controls using the LeBlender package.

Installation

  1. NuGet Package
    Install this NuGet package in your Visual Studio project. Makes updating easy.

  2. ZIP file
    Grab a ZIP file of the latest release; unzip and move the contents to the root directory of your web application.

Usage

Skybrud.Umbraco.GridData relies on a number of converters to provide the strongly typed models for the grid. This package adds a new converter to do just that for controls using LeBlender.

For the converter to handle your controls, the editor alias must start with LeBlender. - eg. LeBlender.Spotbox or LeBlender.Contact.

If a control matches this criteria, the Value property of GridControl will be an instance of GridControlLeBlenderValue, while Editor.Config will be an instance of GridEditorLeBlenderConfig.

A partial view for rendering the entire grid model could look like this:

@using Skybrud.Umbraco.GridData
@inherits UmbracoViewPage<GridDataModel>

@{

    // Stop any further rendering since the model isn't valid
    if (!Model.IsValid) { return; }

    // Compared to "Fanoe.cshtml" from the Fanoe starter kit, it will check and handle in different ways if is just a
    // single section or multiple sections. This examples doesn't since the Umbraco UI doesn't really allow users to
    // add more than one section.

    <div class="umb-grid">
        @foreach (GridSection section in Model.Sections) {
            <div class="grid-section">
                @foreach (GridRow row in section.Rows.Where(x => x.IsValid)) {
                    <div class="grid-row">
                        @foreach (GridArea area in row.Areas) {
                            foreach (GridControl control in area.Controls) {

                                switch (control.Editor.Alias) {

                                    case "LeBlender.ContactPerson": {
                                        @control.GetHtml(Html, "TypedGrid/Editors/LeBlender/ContactPerson")
                                        break;
                                    }
                                    
                                    // other editors omitted for simplicty
  
                                }

                            }
                        }
                    </div>
                }
            </div>
        }
    </div>

}

And the partial view for rendering the contact person could look like:

@using Lecoati.LeBlender.Extension.Models
@using Umbraco.Web.Models
@using Skybrud.Umbraco.GridData.Rendering

@inherits UmbracoViewPage<GridControlWrapper<Skybrud.Umbraco.GridData.LeBlender.Values.GridControlLeBlenderValue>>

@foreach (LeBlenderValue value in Model.Value.Items) {
    
    string name = value.GetValue<string>("name");
    string email = value.GetValue<string>("email");

    IPublishedContent image = Umbraco.TypedMedia(value.GetValue<int>("image"));

    <div>
        <div style="display: flex; margin-top: 15px;">
            <div style="width: 150px; min-height: 35px; margin-right: 10px;">
                <img src="@image.GetCropUrl(150, 150, preferFocalPoint: true, imageCropMode: ImageCropMode.Crop, upScale: false)" />
            </div>
            <div>
                <h2>@name</h2>
                <div class="inner">
                    @email
                </div>
            </div>
        </div>
    </div>

}

skybrud.umbraco.griddata.leblender's People

Contributors

abjerner avatar ronaldbarendse avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

ronaldbarendse

skybrud.umbraco.griddata.leblender's Issues

"Leblender.{Name}" naming convention dependency and custom controller

Because of the "Leblender.{Name}" naming convention dependency, it makes it impossible to customize a controller for this LeBlender controller. Recommend removing "LeBlender." part when creating controller using reflection, or set up a designated naming convention in say, web.config

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.