如何在View启动时检测内容的状态? [英] How can I detect the state of Content at View startup?

查看:58
本文介绍了如何在View启动时检测内容的状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们假设我已经为Link内容类型创建了自己的自定义视图.当用户将2sxc内容应用添加到窗格中,然后选择内容类型(链接),然后选择我的自定义视图时,该视图首次启动时,如何检测到a)该视图未使用演示项目,而b)视图使用了一个演示项目并显示了该演示项目,而c)不是第一次显示,而是有一个真实的用户添加了内容(实体)?

Lets assume I have created my own custom view for a Link content type. When the user adds a 2sxc Content app to a Pane, then picks the Content Type (Link) then my custom View, when it first starts up, how can I detect that a) the View does not use a Demo item vs. b) the View uses a demo item and is showing the Demo item vs. c) its not the first time and there is a real user added Content (Entity) in place?

对于a)情况,我已经做了类似的事情:

I have done stuff like this for the a) case:

var link = AsDynamic(Data["Default"]).First();

然后检查它是否为null,但似乎我的View代码从不执行,相反,我只是看到:所选模板不存在演示项目."

then checked if it was null, but it looks like my View code never executes and instead I just see, "No demo item exists for the selected template."

如果我确实分配了一个演示,是否还有一种更优雅的方式来知道我作为Content.First()或Data ["Default"])的实体.First()是一个演示项目,现在是一个用户创建实体?目前,我正在模板中对EntityId进行硬编码并为此进行测试.

If I do assign a demo, is there a more elegant way to know that the Entity I am handed as Content.First() or Data["Default"]).First() is a Demo item and now a user created Entity? Currently I am hard-coding the EntityId in the template and testing for that.

推荐答案

2sxc 10.06中添加了IsDemoItem属性

IsDemoItem property added in 2sxc 10.06

动态实体

这篇关于如何在View启动时检测内容的状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆