Table of Contents

Class RuleAttributeBase

Namespace
Dynamicweb.Content.Items.Annotations
Assembly
Dynamicweb.dll

Provides information about the item.

[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
public class RuleAttributeBase : Attribute
Inheritance
RuleAttributeBase
Derived
Inherited Members

Examples

using System;
using System.Collections.Generic;
using Dynamicweb.Content.Items;
using Dynamicweb.Content.Items.Activation;
using Dynamicweb.Content.Items.Annotations;
using Dynamicweb.Content.Items.Editors;
using Dynamicweb.Content.Items.Metadata;
using Dynamicweb.Core.UI.Icons;

namespace Dynamicweb.Examples.Items;

[Item("News item", "The example of code-first item")]
[AreaRule,
ModuleAttachmentRule(true),
ParagraphDefaultModuleSystemName(ModuleSystemName = "eCom_ContextOrderRenderer"),
StructureRule(StructureContextType.Pages, StructureContextType.Paragraphs),
ParentRule(ParentRestrictionRule.ParentType.RootOfWebsite, ParentRestrictionRule.ParentType.RegularPage),
ChildRule(true), ChildRule("ExampleCategory", "ExampleRegion")]
[Category("Example")]
[Icon(KnownIcon.Message)]
[TitleField("Title")]
public class ExampleNewsItem : ItemEntry
{
    [Group("MappingFields", LayoutGroupMetadata.GroupCollapsibleState.Collapsed)]
    [Field("Category", typeof(DropDownListEditor<string>))]
    [OptionItem("ExampleCategory", "Name", "Id", SourceType = FieldOptionItemSourceType.CurrentArea)]
    public string NewsCategoryId { get; set; } = "";

    [Group("MappingFields")]
    [Field("Region", typeof(CheckboxListEditor<string>))]
    [OptionItem("ExampleRegion", "Name", "Id", SourceType = FieldOptionItemSourceType.CurrentArea)]
    public IEnumerable<string> RegionId { get; set; }

    [Group("StandardFields")]
    [Required]
    public string Title { get; set; } = "";

    [Group("StandardFields")]
    [Name("Subtitle")]
    [DoNotIncludeInSearch]
    public string Subtitle { get; set; } = "";

    [Group("StandardFields")]
    [Required]
    [RichText]
    public string Text { get; set; } = "";

    [Group("StandardFields")]
    [Name("News date")]
    [DefaultValue("Now")]
    public DateTime NewsDate { get; set; }

    [Group("StandardFields")]
    [Field("Type", typeof(RadioButtonListEditor<string>))]
    [Option("News"), Option("Featured"), Option("Add")]
    [DefaultValue("News")]
    [Required]
    public string NewsType { get; set; } = "";

    [Group("StandardFields")]
    [Color("Background color", Presets = "#FFF, #151515, #444544, #5E5E5E, #005731, #287D59, #31988D, #2D73AB, #384E9A, #703F96, #9F3F95, #A93948, #E6A04B, #DD823A, #9BBF53, #0085CA, #1C588F")]
    [DefaultValue("#151515")]
    public string BackgroundColor { get; set; } = "";

    [Group("StandardFields")]
    [Name("Link to landing page")]
    [Link]
    public string LandingPage { get; set; } = "";

    [Group("StandardFields")]
    [GoogleFont("Google font", "Lato", "italic")]
    public string GoogleFont { get; set; } = "";

    [Group("Misc", LayoutGroupMetadata.GroupCollapsibleState.None, "NewsType", GroupVisibilityRule.VisibilityCondition.NotEqualTo, "Featured")]
    [Name("Tags")]
    [LongText]
    public string Tags { get; set; } = "";

    [Group("Misc")]
    [InputHtml5("Rank", InputType = "Number", Min = 0, Max = 10)]
    [Validate(typeof(RegExValidator), Parameters = "Expression=^$|^[0-9]%2b")] // Short version: [RegEx("^$|^[0-9]%2b")] // %2b - is encoded +
    public int Rank { get; set; }

    [Group("Misc")]
    [ItemRelationList("Related news", "ExampleNewsItem", ItemRelationListEditor.ItemListSource.Page, "Title", "SubTitle")]
    [Option("Title"), Option("Subtitle"), Option("NewsType")]
    public int RelatedNews { get; set; }

    [Group("Misc2", LayoutGroupMetadata.GroupCollapsibleState.None, "NewsType", GroupVisibilityRule.VisibilityCondition.Equals, "Featured")]
    [Name("Tags2")]
    [LongText]
    public string Tags2 { get; set; } = "";

    public ExampleNewsItem()
    {
        NewsCategoryId = "1";
        RegionId = ["1"];
        Title = "New news";
    }

    public override void Delete(ItemContext? context)
    {
        base.Delete(context);
    }
}

Constructors

RuleAttributeBase(Type, string)

Initializes a new instance of an object.

public RuleAttributeBase(Type ruleType, string value)

Parameters

ruleType Type

Type of restriction rule.

value string

value for restriction rule.

Properties

Rule

Gets or sets the creation rule.

public CreationRuleMetadata Rule { get; set; }

Property Value

CreationRuleMetadata
To top