No longer able to get Page Description
Before upgrading to 4.2 I was able to get the page description using the following code, now whatever I try the description is always just an empty string. Any ideas?
protected
void
Repeater_OnItemDataBound(
object
sender, RepeaterItemEventArgs e)
SiteMapNode cNode = e.Item.DataItem
as
SiteMapNode;
PageNode node = (PageNode)cNode;
string
desc = node.Description
// this is now always empty, but used to work
Hi Phill Hodgkinson,
Can you please make sure that you are working with the Description property of the PageData object, not the PageNode? I have just tested the described functionality and it seems to be working fine. PLease take a look at the below sample code:
var myPage = App.WorkWith()
.Pages()
.ThatArePublished()
.LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend)
.Where(p =>p.Page !=
null
&& p.Page.Title ==
"Home"
)
.Get()
.FirstOrDefault();
var descr = myPage.Page.Description;
Hi Boyan,
I will give your sample code a try. I do wonder if this is the most efficient way to get page description since I have to make this call OnDataItemBound for each item in the menu. Also, part of the reason that I posted this issue was that using PageSiteNode worked before upgrading to 4.2 and then it just stopped working (aka another undocumented breaking change).
I'll let you know if the below works for me but again I fear it's not a very efficient way to get a page description.
Regards,
Phill
Hi Boyan,
So your solution doesn't work for me, the page Description always returns as an empty string. I was able to get things to work using the Page manager. The following code works for me, but again I find it strange that I have to do this every time a menu node renders and that there are so many references to page description (i.e. PageSiteNode) but they're always empty.
ISitefinitySiteMapNode smNode = e.Item.DataItem as ISitefinitySiteMapNode;
var pageNode = smNode as PageSiteNode;
var pManager = Telerik.Sitefinity.Modules.Pages.PageManager.GetManager();
PageData page = pManager.GetPageData(pageNode.PageId);
string
desc = page.Description;
Getting similar error with the following code. This use to work in 4.1 but no longer does in 4.2. See the "Eval("Description")" line below.
<%@ Control Language="C#" AutoEventWireup="true" %>
<telerik:RadTabStrip ID="RadPanelpageNav" runat="server" Visible="false" />
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SiteMapDataSource" >
<HeaderTemplate>
<ul class="page-nav-holder">
</HeaderTemplate>
<ItemTemplate>
<li>
<a href='<%# Eval("Url") %>' runat='server'>
<h3><%# Eval("Title") %></h3>
<p><%# Eval("Description") %></p>
</a>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
<asp:SiteMapDataSource runat="server" ID="SiteMapDataSource" StartingNodeOffset="0" ShowStartingNode="false" />
Hi,
you can test this :
SiteMapNode cNode = e.Item.DataItem
as
SiteMapNode;
PageNode node = (PageNode)cNode;
string
desc = node.GetString(
"Description"
);
I have the same issue!
We are using SF
5.0.2500.0
You can try this:
var des = page.GetPageData().Description
// The statement "page.Description" always returns as an empty string. I don't know why
This work for me