如何使用Razor从内容选择器检索数据?
我尝试使用不成功的内容选择器 我创建了一个文档类型,其属性是内容选择器,因此我尝试在杂志上使用此页面来拾取新闻/等功能,并将其显示在主页上。没有成功 我使用了类似于:如何使用Razor从内容选择器检索数据?,razor,umbraco,Razor,Umbraco,我尝试使用不成功的内容选择器 我创建了一个文档类型,其属性是内容选择器,因此我尝试在杂志上使用此页面来拾取新闻/等功能,并将其显示在主页上。没有成功 我使用了类似于: dynamic feature_news_item = Library.NodeById(1111); (tried also the same but with Model: Model.NodeById(1111); Let's say for the example that 1111 is the id of this p
dynamic feature_news_item = Library.NodeById(1111); (tried also the same but with Model: Model.NodeById(1111); Let's say for the example that 1111 is the id of this page which store the content pickers.
同样,页面的属性是“内容选择器”,别名是featureItemNews
现在,我尝试获取/显示内容选择器(据我所知…)应该检索的ID,但只获取错误(或什么都没有…)-尝试了以下示例:
var node = @Library.NodeById(feature_news_item.contentPicker);
<a href="@node.Url">@node.Name</a>
什么都不管用
featureItemNews也是别名
而feature_news_项只是通过内容选择器获取节点(请参见问题开头)
我现在尝试的只是获取存储在内容选择器中的选定节点的ID,并显示/使用它
有什么魔力
非常感谢你的帮助
问题是我需要从其他页面获取此属性,而不是当前页面。所以我尝试了Node myNode=new Node(1234);然后字符串myValue=myNode.GetProperty(“featureItemNews”).Value;不工作…在我的示例中没有“string myValue=myNode.GetProperty(“featureItemNews”).Value;”这样的代码。我已经用“int id=current.GetProperty(“myTestContentPicker”);“为了实验起见,您介意使用int而不使用.Value吗?问题是我需要从其他页面获取此属性,而不是从当前页面。所以我尝试了Node myNode=new Node(1234);然后字符串myValue=myNode.GetProperty(“featureItemNews”).Value;不工作…在我的示例中没有“string myValue=myNode.GetProperty(“featureItemNews”).Value;”这样的代码。我已经用“int id=current.GetProperty(“myTestContentPicker”);“为了实验起见,您介意使用int而不使用.Value吗?”?
var node = @Library.NodeById(feature_news_item.featureItemNews);
int story1 = @feature_story.featureItemNews
var current = umbraco.NodeFactory.Node.GetCurrent();
int id = current.GetProperty<int>("myTestContentPicker");
< h1>@id< /h1>
var node = new Node(id);