Sitecore ページ エディターで、head html セクションのメタ フィールドなどの非表示フィールドを編集したいと考えています。どうすればいいですか?私は試してみます
<sc:FieldRenderer runat="server" ID="scFieldMeta" FieldName="Meta title" />
しかし、これは head html セクションでは機能しません。
Sitecore ページ エディターで、head html セクションのメタ フィールドなどの非表示フィールドを編集したいと考えています。どうすればいいですか?私は試してみます
<sc:FieldRenderer runat="server" ID="scFieldMeta" FieldName="Meta title" />
しかし、これは head html セクションでは機能しません。
Sitecore にはこの種の機能がすぐに使えるわけではありませんが、それを行うにはいくつかの手順に従う必要があります。
アイテムの下に作成
/sitecore/content/Applications/WebEdit/Edit Frame Buttons
フォルダーには、次のように名前を付けることができます: PageProperties. フォルダーの下に、新しいフィールド エディター ボタンを作成する必要があります。フィールド フィールドでは、編集するフィールドの名前をパイプラインごとに入力する必要があります。次のようになります。
Meta data|Meta title
アイテムの下:
/sitecore/content/Applications/WebEdit/Ribbons/WebEdit/Page Editor
次のタイプのアイテムを作成する必要があります。
/sitecore/templates/System/Ribbon/Chunk
新しいアイテムの下に、次のタイプの新しいアイテムを作成する必要があります。
/sitecore/templates/System/Ribbon/Small Button
フィールドをクリックすると、次のようなものが表示されます
command:executefieldeditor(path=/sitecore/content/Applications/WebEdit/Edit Frame Buttons/Page Properties/Page Properties)
path は、ステップ 1 で作成されたアイテムを指します。
このステップでは、コマンドを作成する必要があります。インクルード フォルダーに新しいファイル名を作成してください: CustomCommands.config または拡張構成をどのように使用しますか。
それは含まれます:
<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<commands>
<command name="command:executefieldeditor" type="yournamespace.ExecuteFieldEditor,yourAssembly"/>
</commands>
</sitecore>
</configuration>
using Sitecore; using Sitecore.Data; using Sitecore.Data.Items; using Sitecore.Diagnostics; using Sitecore.Shell.Applications.WebEdit; using Sitecore.Shell.Applications.WebEdit.Commands; using Sitecore.Text; using Sitecore.Web.UI.Sheer; using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Text; using System.Threading.Tasks; namespace YOURNAMESPACENAME { public class ExecuteFieldEditor : FieldEditorCommand { /// <summary> /// The fieldname /// </summary> private const string Fieldname = "Fields"; /// <summary> /// The header /// </summary> private const string Header = "Header"; /// <summary> /// The icon /// </summary> private const string Icon = "Icon"; /// <summary> /// The uriparameter /// </summary> private const string Uriparameter = "uri"; /// <summary> /// The pathparameter /// </summary> private const string Pathparameter = "path"; /// <summary> /// The currentitemisnull /// </summary> private const string Currentitemisnull = "Current item is null"; /// <summary> /// The settingsitemisnull /// </summary> private const string Settingsitemisnull = "Settings item is null"; /// <summary> /// Gets or sets the current item. /// </summary> /// <value> /// The current item. /// </value> private Item CurrentItem { get; set; } /// <summary> /// Gets or sets the settings item. /// </summary> /// <value> /// The settings item. /// </value> private Item SettingsItem { get; set; } /// <summary> /// Gets the options. /// </summary> /// <param name="args">The arguments.</param> /// <param name="form">The form.</param> /// <returns></returns> protected override PageEditFieldEditorOptions GetOptions(ClientPipelineArgs args, NameValueCollection form) { EnsureContext(args); return new PageEditFieldEditorOptions(form, BuildListWithFieldsToShow()) { Title = SettingsItem[Header], Icon = SettingsItem[Icon] }; } /// <summary> /// Ensures the context. /// </summary> /// <param name="args">The arguments.</param> private void EnsureContext(ClientPipelineArgs args) { CurrentItem = Database.GetItem(ItemUri.Parse(args.Parameters[Uriparameter])); Assert.IsNotNull(CurrentItem, Currentitemisnull); SettingsItem = Client.CoreDatabase.GetItem(args.Parameters[Pathparameter]); Assert.IsNotNull(SettingsItem, Settingsitemisnull); } /// <summary> /// Builds the list with fields to show. /// </summary> /// <returns></returns> private IEnumerable<FieldDescriptor> BuildListWithFieldsToShow() { ListString fieldString = new ListString(SettingsItem[Fieldname]); return (from field in new ListString(fieldString) where CurrentItem.Fields[field] != null select new FieldDescriptor(CurrentItem, field)).ToList(); } } }
また、この投稿を確認できます。