Code Monkey home page Code Monkey logo

gecko.episerver.iconselectioneditor's Introduction

Platform

Icon Selection Editor for EPiServer.

Module which extends EPiServer edit mode by adding possibility to select icons (i.e. Font Awesome, Materialize, CSS.gg etc.) using dropdown.

How to create and use IconSelectionEditor.

  1. Create model class which will represent icon:
public class CustomIconSelectItem : IconSelectItem
{
    public override string ToHtmlString()
    {
        (...)
    }
}

Here we can specify:

  • Id: Unique id of an icon - this value will be stored in DB.
  • Name: Friendly name which can be used during filtering.
  • KeyWords: Keyword which can be used during filtering.
  1. Create IconSelectionFactory which will return all available icons:
public class CustomIconSelectionFactory : IconSelectionFactory
{
    public override IEnumerable<IconSelectItem> GetIcons(ExtendedMetadata metadata)
    {
        (...)
    }
}
  1. Create property attribute:
public class SelectCustomIconAttribute : SelectIconAttribute
{
    public SelectCustomIconAttribute()
    {
        this.SelectionFactoryType = typeof(CustomIconSelectionFactory);
        this.IconsPerRow = 5;
    }
}

Here we can specify:

  • IconsPerRow: how many icons should be displayed in a row.
  • RequireClientResources: additional resources which should be loaded with widget (i.e. css with icons).
  • Filterable: possibility to filter icons by name or keywords.
  • SelectionFactoryType: Our factory created in 2.
  1. Decorate EPiServer content model property using created custom attribute:
[ContentType(DisplayName = "Custom Content Block", GUID = "d1216b39-21ce-4873-a8c1-c3d5db2b9285")]
public class CustomContentBlock : BlockData
{
    [SelectCustomIcon]
    public virtual string Icon { get; set; }
}

gecko.episerver.iconselectioneditor's People

Contributors

realgecko avatar

Watchers

 avatar

gecko.episerver.iconselectioneditor's Issues

Unable to load custom resource

I can't figure out how to load a custom css using the RequireClientResources property. I have tried different approaches:

  • created a custom client resource provider, but the resource is always trying to be taken from the Episerver Shell instead of my provider. In this case, I'm passing my resource name to the RequireClientResources property.
  • I have also included the path to the file into the RequireClientResources. In this case the file is loaded but with a mime-type of javascript, so the css doesn't load.

Are you able to provide an example, please?

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.