Fork me on GitHub
2sxc 9.8 for DNN 7 to 9
Website Builder, Content Manager, App-System: open-source and amazing
You are here: Home  >  Docs  >  Prefill new Forms
Error rendering template

Look inside

Content Item

These are the values a content-editor can manage.
Name Type Value
Title System.String Prefill Form for New Entity
Teaser System.String Sometimes you want to pre-fill a new Entity with existing information - like the current date, the users name, or data from another list like a file-ID or infos from an XML-Stream. This is now possibl...
AddedInVersion System.String 05.05.01
DescriptionLong System.String <p>Sometimes you want to pre-fill a new Entity with existing information - like the current date, the users name, or data from another list like a file-ID or infos from an XML-Stream. This is now poss...
ImageTeaser System.String
Image System.String
DocumentedOnPage System.String Page:465
StatusDocumentation System.String 2
StatusDevelopment System.String 10
DesignedContent ToSic.Eav.Data.EntityRelationship
ReplacementDocs null
Tags ToSic.Eav.Data.EntityRelationship 1848,1844,1861,1910,2440
RelatedFeatures ToSic.Eav.Data.EntityRelationship 1929,2875,2439
DemoAppGuid System.String
DemoPage System.String


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.Interfaces.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.