Skip to content

Instantly share code, notes, and snippets.

View simple17's full-sized avatar

Alexander Khripko simple17

  • FirstLine software
  • Montenegro
View GitHub Profile
@simple17
simple17 / blockData.cs
Last active February 28, 2019 13:55
[Common Model] Episerver common block data #episerver #c#
using System.ComponentModel.DataAnnotations;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.DataAnnotations;
using DigiOne.Core.DataAbstraction;
using DigiOne.Core.Styles;
using EPiServer;
namespace SomeName.Project.Areas.Layout.Models
@simple17
simple17 / data.cs
Created March 27, 2018 10:26
[Epi Property types] Episerver common property types #episerver #c#
[Display(
Name = "Autoplay",
Description = "Autoplay",
GroupName = SystemTabNames.Content,
Order = 70)]
public virtual bool Autoplay { get; set; }
[Display(
Name = "Width",
Description = "Width",
@simple17
simple17 / commerce.cs
Last active June 28, 2019 14:12
[Epi Property attributes] episerver Property attributes #episerver #c#
////Show only commerce content
[UIHint(EPiServer.Commerce.UIHint.CatalogContent)]
@simple17
simple17 / VideoFile.cs
Created November 16, 2018 08:34
[Media type] To make new filetypes available for uploading you need to declare class for each type. #episerver #c#
using EPiServer.Core;
using EPiServer.DataAnnotations;
using EPiServer.Framework.DataAnnotations;
namespace SomeName.Project.Media
{
[ContentType]
[MediaDescriptor(ExtensionString = "flv,mp4,webm,ogv")]
public class VideoFile : VideoData
{
@simple17
simple17 / UniqueId.cshtml
Created November 16, 2018 08:35
[Unique IDs] #c#
@{
var uniqueId = string.Format("carousel-{0:N}", Guid.NewGuid());
}
@simple17
simple17 / SelectionFatory.cs
Created November 16, 2018 08:37
[Seletion Factory] Simple select or list checkboxes property #episerver
using System.Collections.Generic;
using System.Linq;
using EPiServer.Shell.ObjectEditing;
namespace Project.Business.Selection
{
public class ResourceIconSelection : ISelectionFactory
{
public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata)
{
@simple17
simple17 / EpiserverGetCategory.cs
Created November 16, 2018 08:38
[Get Category] #episerver
var category = article.Category.Any() ? Category.Find(article.Category.First()).LocalizedDescription : string.Empty;
@simple17
simple17 / EpiGetChildren1.cs
Last active May 12, 2020 11:45
[Get children] #episerver
private readonly IContentLoader _contentLoader;
////...
var children =
FilterForVisitor.Filter(
_contentLoader.GetChildren<TesArticlePage>(currentPageReference, LanguageSelector.AutoDetect()))
.OfType<TesArticlePage>()
.Select(this.toArticleListItem);
@simple17
simple17 / script
Created November 20, 2018 13:52
[Uncommit] Uncommit last commit then stash #git
git reset --soft HEAD^
git stash
git pull
git stash apply
@simple17
simple17 / example.cs
Created November 30, 2018 11:37
[Set default propertie value] #episerver
public override void SetDefaultValues(ContentType contentType)
{
base.SetDefaultValues(contentType);
Height = 240;
Width = 320;
}