Fork me on GitHub
2sxc 8.11 for DNN 7 to 9
Website Builder, Content Manager, App-System: free and amazing - done your way
You are here: Home  >  Docs  >  Relationship Management connecting Entities

Relationship Management connecting Entities

Introduced in Version 05.03.00

Not fully documented :(. Please watch the video and the live-demos

Note that to really use this powerful feature you must use Razor-Templates. 

Also - the list below is also created using relationships. Click on Look inside to see the code.

Tags for this feature

Look inside

Content Item

These are the values a content-editor can manage.
Name Type Value
Title System.String Relationship Management connecting Entities
Teaser System.String Now you can connect entities (like authors and books) in awesome ways. Also extremely usefull for tagging and similar scenarios.
AddedInVersion System.String 05.03.00
DescriptionLong System.String <p>Not fully documented :(. Please watch the <a href="http://2sexycontent.org/en-us/learn.aspx#FancyDetails-1583" target="_blank">video</a> and the <a href="http://2sexycontent.org/learn-razor/en-us/r...
ImageTeaser System.String
Image System.String
DocumentedOnPage System.String Page:428
StatusDocumentation System.String 3
StatusDevelopment System.String 10
Tags ToSic.Eav.Data.EntityRelationship 1844, 1843, 1846, 1848, 1840, 3197
RelatedFeatures ToSic.Eav.Data.EntityRelationship 1903
DemoAppGuid System.String
DemoPage System.String
DesignedContent ToSic.Eav.Data.EntityRelationship
ReplacementDocs null


Presentation Item

These are additional, optional presentation instructions a content-editor can manage. If none are entered, a default set (predefined by the designer) will be used.

No Presentation parameters specified, using default presentation for this item.


Template file

@using ToSic.Eav.DataSources
@{
	var feature = Content;
	int featureNumber = 0;
	int.TryParse(Request.QueryString["Feature"], out featureNumber); // try from QS
	if (featureNumber > 0)
	{
		var featSource = CreateSource<EntityIdFilter>();
		featSource.EntityIds = featureNumber.ToString();
		var found = featSource.List.FirstOrDefault().Value;
		if (found != null)
		{
			feature = AsDynamic(found);
		}
	}
}

<div class="ym-clearfix co-full-width-inner co-box-with-image sc-element">
    @if(Permissions.UserMayEditContent)
    {
        if (feature.Title != "Demo Feature")
        {
            @*currently not showing the demo-entity, so show the normal toolbar*@
            @feature.Toolbar
        }
        else
        {
            @*currently showing the demo-entity, so show the prefill-edit-button            
<ul class="sc-menu-deactivated">
                <li>
                    <a class="sc-menu-edit" href="javascript: $2sxc(@Dnn.Module.ModuleID).manage.openDialog({ action: 'edit', moduleId: @Dnn.Module.ModuleID, tabId: @Dnn.Tab.TabID, contentGroupId: @List.First().GroupId, sortOrder: 0, returnUrl: 'Default.aspx?tabId=@Dnn.Tab.TabID', prefill: { DocumentedOnPage: 'Page:@Dnn.Tab.TabID', Title: '@Dnn.Tab.Title' }}); ">create for this page <img src="/DesktopModules/ToSIC_SexyContent/Images/Edit.png" /></a>
                </li>
            </ul>*@
	<ul class='sc-menu' data-toolbar='[{"action":"edit", "useModuleList":true, "sortOrder": 0, "prefill": { "DocumentedOnPage": "page:@Dnn.Tab.TabID", "Title": "@Dnn.Tab.Title" } }]'></ul>

        }
    }
    <div>
        <div class="@if (!String.IsNullOrEmpty(feature.Image)) {<text>ym-g50</text>} ym-gl">
            <div class="ym-gbox-half">
                <h1>@feature.Title</h1>
                
                @if(!String.IsNullOrEmpty(feature.ReplacementDocs)) {
                   <h2>Important: new docs available</h2>
                   <div>This information has been improved so it's best to <a href="@feature.ReplacementDocs" target="_blank">continue in the new wiki</a>.</div>
                   <div>This page is currently still left here so old links will continue to work, but the content is not updated any more. </div>
                   <br/>
                   <br/>
                }

	            <div><em>Introduced in Version @feature.AddedInVersion</em></div>
				@if (!String.IsNullOrEmpty(feature.DemoPage) || !String.IsNullOrEmpty(feature.DemoAppGuid))
				{
					<div><strong>Demos of this feature</strong>
				<ul>
						@if (!String.IsNullOrEmpty(feature.DemoPage))
						{
							<li><a href="@feature.DemoPage">live demo</a></li>
						} 
						@if (!String.IsNullOrEmpty(feature.DemoAppGuid))
						{
							<li><a href="/en/Apps/Details?AppGuid=@feature.DemoAppGuid">try this App</a></li>

						}</ul>
					</div>
				}
                <div>@Html.Raw(feature.DescriptionLong)</div>
            </div>
        </div>

        @if (!String.IsNullOrEmpty(feature.Image))
        {
            if (Presentation != null && Presentation.ImageAction == "block")
            {
                @:<a href="@feature.Image" class="fancybox">
			}

            <div class="ym-g50 ym-gr co-image-space" style="text-align:right;">
                <img src="@feature.Image?w=454" />
            </div>

            if (Presentation != null && Presentation.ImageAction == "block")
            {
                @:</a>
			}
        }
    </div>
    
</div>

<div class="sc-content-block-list" @Edit.ContextAttributes(Content, field: "DesignedContent")>
    @foreach(var contentBlock in Content.DesignedContent){
        @contentBlock.Render()
    }
</div>


@{
    // Here's some special stuff necessary to find all related features
    // 1. leave the simple API, go to the power API of entities, must be typed to work
    ToSic.Eav.IEntity ent = AsEntity(feature);

    // 2. Get all incomming and outgoing relationships (all parents & children)
    var entitiesReferringToThis = ent.Relationships.AllParents.Union(ent.Relationships.AllChildren);

    // 3. Filter. We only want relationships to the same type of data
    // 4. Make sure we don't have duplicates with Distinct()
    var RelFeatures = entitiesReferringToThis.Where(c => c.Type.Name == "2SexyContent Feature").Distinct();
}
@if (RelFeatures.Count() > 0)
{
<div class="ym-clearfix co-full-width-inner">
    <h2>Related Features</h2>
    <ol>
        @foreach (var feat in RelFeatures)
        {
            var dynFeat = AsDynamic(feat);
            <li><a href="@(!String.IsNullOrEmpty(dynFeat.DocumentedOnPage) ? dynFeat.DocumentedOnPage : "/en-us/docsmanuals/feature.aspx?feature=" + dynFeat.EntityId)">@dynFeat.Title</a></li>
        }
    </ol>
</div>
}

<h2>Tags for this feature</h2>
<ul>
    @foreach (var tag in feature.Tags)
    {
        <li><a href="/en/Docs-Manuals?tag=@tag.Tag">@tag.Tag</a></li>
    }
</ul>
2serve . 2invent . 2create is 2be.