<%@ Page Language="C#" MasterPageFile="~/masterpages/content.master" AutoEventWireup="true" CodeFile="boardlanding.aspx.cs" Inherits="templates_categorylanding" Title="Category Landing Page" %> <%@ Register Assembly="Ektron.Cms.Controls" Namespace="Ektron.Cms.Controls" TagPrefix="CMS" %> <%@ Register Src="~/usercontrols/breadcrumb.ascx" TagName="Breadcrumb" TagPrefix="uc" %> <asp:Content ID="Header" ContentPlaceHolderID="ContentHeaderContentPlaceHolder" runat="server"> <!-- categorylanding --> <img class="banner" alt="banner" src="/img/banner_01.jpg"> </asp:Content> <asp:Content ID="Left" ContentPlaceHolderID="LeftContentPlaceHolder" runat="Server"> <div id="crumbs"> <uc:Breadcrumb ID="breadcrumbControl" runat="server" /> </div> <img class="divider upper" alt="" src="/img/divider.png"> </asp:Content> <asp:Content ID="Mid" ContentPlaceHolderID="MidContentPlaceHolder" runat="Server"> <h1> <asp:Label ID="pageTitle" runat="server"></asp:Label> </h1> <CMS:ContentBlock ID="contentBlock" runat="server" /> <img class="divider" alt="" src="/img/divider.png"> <asp:ListView ID="lvTEST" runat="server"></asp:ListView> <asp:Repeater ID="subContentRepeater" runat="server"> <ItemTemplate> <table> <tr> <td style="vertical-align: text-top; padding: 5px;"> <strong>Name:</strong> </td> <td style="vertical-align: text-top; padding: 5px;"> <a href="<%# MakeAbsolutePath((string)DataBinder.Eval(Container.DataItem, "QuickLink")) %>" class="cat_sub_link" <%# string.IsNullOrEmpty(GetContentTarget((Ektron.Cms.ContentData)Container.DataItem)) ? "" : "target='" + GetContentTarget((Ektron.Cms.ContentData)Container.DataItem) + "'" %>><strong><%# DataBinder.Eval(Container.DataItem, "Title") %></strong></a><br /> <%# DataBinder.Eval(Container.DataItem, "Id").ToString() %> </td> </tr> <tr> <td style="vertical-align: text-top; padding: 5px;"> <strong>Summary:</strong> </td> <td style="vertical-align: text-top; padding: 5px;"> <%# HealthPlus.Cms.Custom.Utility.RemoveParagraphTags(DataBinder.Eval(Container.DataItem, "Teaser").ToString())%> </td> </tr> </table> </ItemTemplate> <SeparatorTemplate> <img class="divider" alt="" src="/img/divider.png"> </SeparatorTemplate> </asp:Repeater> </asp:Content> <asp:Content ID="Footer" ContentPlaceHolderID="FooterPlaceHolder" runat="server"> <a href="#"> <asp:Literal ID="ltlTitle" runat="server"></asp:Literal></a> <span> <asp:Literal ID="ltlUpdated" runat="server"></asp:Literal></span> </asp:Content>
using HealthPlus.Cms.Custom;
using HealthPlus.Cms.Custom.SmartForms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Globalization;
using Ektron.Cms;
using Ektron.Cms.Common;
using Ektron.Site;
using Ektron.Cms.API;
using Ektron.Cms.Messaging;
using Ektron.Cms.Search;
using Ektron.Cms.Content;
using Ektron.Cms.Search.Expressions;
using Ektron.Cms.Framework.Settings;
using Ektron.Cms.Framework.Content;
using Ektron.Cms.Framework.Organization;
public partial class templates_categorylanding : LandingPageBuilder
{
protected void Page_Load(object sender, EventArgs e)
{
System.Web.UI.WebControls.Literal sectionTitle = (System.Web.UI.WebControls.Literal)FindControlRecursive("SectionTitleLiteral");
Build(contentBlock, sectionTitle, pageTitle, ltlTitle, ltlUpdated);
breadcrumbControl.Fill(ContentFolder, ContentData);
if (Context.Items.Contains("ContentId") && Context.Items.Contains("FolderId"))
{
long contentID = System.Convert.ToInt64(Context.Items["ContentId"].ToString());
long folderID = System.Convert.ToInt64(Context.Items["FolderId"].ToString());
}
#region test code
//Ektron.Cms.ContentAPI api = new Ektron.Cms.ContentAPI();
//int j = 0;
//Ektron.Cms.ContentData[] data = api.GetChildContentByFolderId(2147483941, true, "id", 0, ref j, 20);
//lvTEST.DataSource = data;
//lvTEST.DataBind();
#endregion test code
List<Ektron.Cms.ContentData> subContent = new List<Ektron.Cms.ContentData>();
/*subContent.AddRange(GetFolderContent(FolderId, ContentDescriptor.Type.Detail));
subContent.AddRange(GetFolderContent(FolderId, ContentDescriptor.Type.Plan));
*/
subContent.AddRange(GetFolderContentNew(FolderId, ContentDescriptor.Type.Detail));
subContent.AddRange(GetFolderContentNew(FolderId, ContentDescriptor.Type.Plan));
subContent.Sort(DefaultComparer);
// added this logic to replace the closing Anchor tag with an
// anchor tag + line break to separate the links that appear under the main
// link. 4-26-2010 JT
for (int i = 0; i < subContent.Count; i++)
{
subContent[i].Teaser = subContent[i].Teaser.Replace("</a>", "</a><br />");
}
subContentRepeater.DataSource = AddLibraryData(subContent.ToArray());
subContentRepeater.DataBind();
subContentRepeater.Visible = subContentRepeater.Items.Count > 0;
//quicklinksBox.DataSource = new SmartFormView(GetRelatedContent(ContentDescriptor.Type.QuickLink));
//quicklinksBox.DataBind();
//promotionsBox.DataSource = new SmartFormView(GetRelatedContent(ContentDescriptor.Type.Promotion, 1));
//promotionsBox.DataBind();
}
protected override string GetContentTarget(Ektron.Cms.ContentData content)
{
if (content.XmlConfiguration != null && content.XmlConfiguration.Title == "SubimoQuicklink")
{
return "_blank";
}
else
return base.GetContentTarget(content);
}
protected List<ContentData> GetFolderContentNew(long folder, ContentDescriptor.Type type)
{
var results = new List<ContentData>();
ContentManager contentManager = new ContentManager(Ektron.Cms.Framework.ApiAccessMode.LoggedInUser);
ContentCriteria criteria = new ContentCriteria();
criteria.AddFilter(ContentProperty.FolderId, CriteriaFilterOperator.EqualTo, folder);
//if (type != null)
//{
// criteria.AddFilter(ContentMetadataProperty.Value,CriteriaFilterOperator.EqualTo, type.ToDescriptionString());
//}
criteria.PagingInfo.RecordsPerPage = 1000;
criteria.ReturnMetadata = true;
List<ContentData> contentList = contentManager.GetList(criteria);
foreach (var s in contentList)
{
var item = new ContentData()
{
Id = s.Id,
Title = s.Title.ToString(),
Teaser = s.Teaser.ToString(),
Quicklink = s.Quicklink.ToString(),
Path = s.Path.ToString()
};
if (type != null)
{
foreach (var m in s.MetaData)
{
if (m.Text == type.ToString() && m.Name == "TypeOfContent")
{
results.Add(item);
}
}
}
else
{
results.Add(item);
}
}
return results;
}
}
Originally Posted on October 31, 2014
Last Updated on October 26, 2015
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.