This is how I create Sitemap content (pages, inline and dynamic) in Sitefinity 6.1.
, URL-.
ISite currentSite = ((MultisiteContext) SystemManager.CurrentContext).CurrentSite;
using (var manager = PageManager.GetManager())
{
var nodes = manager.GetPageNodes().Where(p =>
p.RootNodeId == currentSite.SiteMapRootNodeId &&
p.NodeType == Telerik.Sitefinity.Pages.Model.NodeType.Standard &&
p.ShowInNavigation);
foreach (var node in nodes)
{
if (!node.Page.IsBackend &&
node.Page.Status == ContentLifecycleStatus.Live &&
node.Page.Visible)
{
string host = getPageHost(serverPort, serverName, node.Page.RequireSsl);
var url = string.Concat(host, VirtualPathUtility.ToAbsolute(node.GetFullUrl()));
}
}
}
-
using (var manager = NewsManager.GetManager())
{
var newsItems = manager.GetNewsItems().Where(p =>
p.Status == ContentLifecycleStatus.Live && p.Visible).ToList();
foreach (var item in newItems)
{
var location = SystemManager.GetContentLocationService().GetItemDefaultLocation(item);
if (location != null)
{
var fullUrl = location.ItemAbsoluteUrl;
}
}
}
ISite currentSite = ((MultisiteContext) SystemManager.CurrentContext).CurrentSite;
var providers = currentSite.GetProviders("YourModuleName").Select(p => p.ProviderName).ToList();
foreach (string provider in providers)
{
var dynamicType = TypeResolutionService.ResolveType("Fully.Qualified.Name.Of.Your.Dynamic.Type");
if (dynamicType != null)
{
using (var manager = DynamicModuleManager.GetManager(providerName))
{
var dynamicTypeItems = manager.GetDataItems(dynamicType).Where(p =>
p.Status == ContentLifecycleStatus.Live && p.Visible).ToList();
foreach (var item in dynamicTypeItems)
{
var location = SystemManager.GetContentLocationService().GetItemDefaultLocation(item);
if (location != null)
{
var fullUrl = location.ItemAbsoluteUrl;
}
}
}
}
}