Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ Page Language="c#" AutoEventWireup="true" Debug="true" %>
- <%@ Import Namespace="Sitecore.Data.Items" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html>
- <head>
- <title>List of URLs</title>
- </head>
- <body>
- <script language="C#" runat="server">
- string domain = "http://mysite.com";
- int count = 0;
- void Page_Load(object sender, System.EventArgs e)
- {
- Sitecore.Data.Database web = Sitecore.Configuration.Factory.GetDatabase("web");
- var home = web.GetItem("/sitecore/content/MySite/home");
- var pages = GetChildren(home);
- Response.Write(pages);
- Response.Write("Total # of pages: " + count.ToString());
- }
- private string GetChildren(Item home)
- {
- string result = "";
- if (!home.HasChildren) return "";
- var childList = home.GetChildren();
- foreach(Item item in childList)
- {
- if (DoesSitecoreItemHavePresentation(item))
- {
- result += domain + Sitecore.Links.LinkManager.GetItemUrl(item) + "<br />";
- count++;
- }
- result += GetChildren(item);
- }
- return result;
- }
- public bool DoesSitecoreItemHavePresentation(Item item)
- {
- return item.Fields[Sitecore.FieldIDs.LayoutField] != null
- && item.Fields[Sitecore.FieldIDs.LayoutField].Value != String.Empty;
- }
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment