[英]sitefinity get docs from module
I want to a Pdf
field in this module. 我想要此模块中的
Pdf
字段。 I want to reach pdf full url and name but don't know how to do in sitefinity. 我想输入pdf完整网址和名称,但不知道该怎么做。 Can somebody help me?
有人可以帮我吗?
asp.x asp.x
<asp:Repeater ID="rptList" runat="server" OnItemDataBound="rptList_ItemDataBound">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblTitle" runat="server" Text='<%# Eval("Title") %>'></asp:Label>
<asp:Label ID="lblSummary" runat="server" Text='<%# Eval("Content") %>'></asp:Label>
<div>
<asp:Repeater ID="rptPdfList" runat="server" >
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<li>
<asp:HyperLink ID="hlSubMenu" runat="server" Text='<%# Eval("Name") %>' NavigateUrl='<%# Eval("Url") %>'
onclick='return handleHyperLinkClick(this)'></asp:HyperLink>
</li>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
</div>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
.cs .cs
private Guid guid { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string id = Request.QueryString["id"];
guid = new Guid(id);
var myCollection = GetDataItems();
rptList.DataSource = myCollection;
rptList.DataBind();
}
}
public IQueryable<DynamicContent> GetDataItems()
{
DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
Type newsReleasesType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.NewsReleases.NewsReleases");
var myCollection = dynamicModuleManager.GetDataItems(newsReleasesType).Where(i => i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && i.Id == guid);
return myCollection;
}
protected void rptList_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
DataTable dtChildNodes = new DataTable();
dtChildNodes.Columns.Add("Name", typeof(string));
dtChildNodes.Columns.Add("Url", typeof(string));
var myCollection = GetDataItems();
foreach (var mp in myCollection)
{
ContentLink cl = ((ContentLink[])mp.GetValue("Pdf"))[0];
dtChildNodes.Rows.Add(cl.ChildItemProviderName, cl.ChildItemAdditionalInfo);
}
Repeater rpt = (Repeater)e.Item.FindControl("rptPdfList");
rpt.DataSource = dtChildNodes;
rpt.DataBind();
}
you're definitely on the right track! 您绝对是在正确的轨道上! the ContentLink[] is how the media is stored, because it's actually storing a reference to a library item.
ContentLink []是媒体的存储方式,因为它实际上是在存储对库项目的引用。
You simply need to pass the ChildItemId from the content link (c1.ChildItemId) to a LibraryManager.Get method (like GetImage or GetDocument) to get the actual content item. 您只需要将ChildItemId从内容链接(c1.ChildItemId)传递到LibraryManager.Get方法(如GetImage或GetDocument)即可获取实际的内容项。
From there you can simply do Content.Url to get the actual link to the library item. 从那里,您可以简单地执行Content.Url来获取到库项目的实际链接。
There is an example of this on the Sitefinity blogs here: http://www.sitefinity.com/blogs/joshmorales/posts/josh-morales-blog/2012/01/19/retrieving_data_from_dynamic_modules_using_the_module_builder_api 此处的Sitefinity博客中有一个示例: http : //www.sitefinity.com/blogs/joshmorales/posts/josh-morales-blog/2012/01/19/retrieving_data_from_dynamic_modules_using_the_module_builder_api
I hope this is helpful! 我希望这是有帮助的!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.