Sitecore Page Editor Publishing items related to content

时光怂恿深爱的人放手 提交于 2019-12-10 16:46:43

问题


I have a "Product Page",Product page maps to "ProductPage" Sitecore item. Website/Pages/ProductPage.

I have a text area in that page with page editor, which loads text from "Product Example Text" Sitecore item's "Description" text from Web database. (Sitecore.../CommonText/Product Example Text)

In my ascx file, mark up is pretty straigh forwad,

<sc:FieldRenderer ID="FieldRenderer1" runat="server" />

Codebehind,

FieldRenderer1.Item = //"Product Example Text" Sitecore item
FieldRenderer1.FieldName = "Description";

When I open the page in Page Editor(as a system admin), it allows me to change the "Product Example Text", and when I save using the "Save" button on the Page Editor it get saved to the master database. "Product Example Text" item get saved. Now, when I try to publish the item using the "Publish" item in the Page Editor ribbon, these changes do not get reflected,reason is "Product Example Text" item does not get published.

When I save the page, somehow Sitecore understands the "Product Example Text" item has to be saved. But why does not it get published? Am I doing anything wrong.... How can I solve this issue?


回答1:


While saving an item in Page Editor, Sitecore saves all the field renderers which are displayed on the page, so if you set the Item property of a FieldRenderer1 to "Product Example Test" Sitecore Item, Page Editor know which item should be saved.

The problem with publishing is that you enqueue the current item in the publishing queue, but this item has no link to the "Product Example Test" Sitecore Item in any of its properties cause you're setting the Item property of the field renderer dynamically in the code.

The option would be to add another button to Page Editor next to Edit Related Item button and create a command that will Publish Related Item. The complete description how to add such a command can be found in the answer Sitecore page editor - how to extend page editor item editing panel




回答2:


Another approach would be to create the "Product Example Test" content item under the "ProductPage" as a sub item. In publish options you can use publish sub items, which will publish all content you want. But the problem is, if you want a particular content to be shared in several places, this won't work. Maras's answer is a better solution.



来源:https://stackoverflow.com/questions/18348988/sitecore-page-editor-publishing-items-related-to-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!