---
title: "例:シンジケーションエントリータイトルの長さ制限"
slug: "example--syndication-entry-title-length-limit"
abstract: ""
---
# 例:シンジケーションエントリータイトルの長さ制限

以下の例に基づいて、RSSエントリタイトルの長さを制限するカスタムフィードを実装できます。

Visual StudioのWebアプリケーションプロジェクトでは、以下の例に基づいてクラスを追加します。

namespace Sitecore.Sharedsource.Syndication {
	using System;
	using System.ServiceModel.Syndication;

	public class LimitedTitleFeed: Sitecore.Syndication.PublicFeed
	{
		protected override SyndicationItem RenderItem(Sitecore.Data.Items.Item item)
		{
			SyndicationItem entry = base.RenderItem(item);

			int titleLengthLimit;

			if (this.FeedItem != null

			&& Int32.TryParse(this.FeedItem"TitleLengthLimit", out titleLengthLimit))

			{

				string title = entry.Title.Text.Substring(0, titleLengthLimit - 3);

				title = title.TrimEnd(new {
					' ',
					',',
					';'
				}) + "...";

				entry.Title = new TextSyndicationContent(title);
			}

			return entry;
		}
	}
}

**コンテンツエディター**で、カスタムフィードデータテンプレートに基づいてフィードを作成します。

コンテンツエディターのフィード定義項目のTitleLengthLimit欄で、シンジケーションエントリのタイトルに使える最大文字数を入力します。

**コンテンツエディター**のフィード定義項目、拡張性セクションのタイプフィールドで、.NETタイプの署名を入力します。以下のように:

Sitecore.Sharedsource.Syndication.SelectionFeed, Assembly