Sitecore Page Editor Publish Content Related Articles

I have a "Product Page" page, the product page corresponds to the Sitecore "ProductPage" element. Website / Pages / ProductPage.

I have a text area on this page with a page editor that loads the text from the "Product example text" Sitecore text "Description" from the web database. (Sitecore ... / CommonText / sample product text)

In my ascx file, note that this is rather inconvenient,

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

CodeBehind

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

When I open a page in the page editor (as a system administrator), this allows me to change the "text of the product example", and when I save using the "Save" button in the page editor, it is saved in the main database. The item "Product Example Text" will be saved. Now, when I try to publish an element using the โ€œPublishโ€ element on the page editor ribbon, these changes will not be reflected, the reason is โ€œProduct example textโ€ is not published.

When I save the page, somehow Sitecore understands that the "Product Example Text" element needs to be saved. But why is it not published? I am doing something wrong ... How can I solve this problem?

+4
source share
2 answers

When you save an item to the Page Editor , Sitecore saves all the field renderers that appear on the page, so if you set the Item property to FieldRenderer1 on the "Product Example Test" Sitecore Item , the Page Editor knows which item to save.

The problem with publishing is that you are inserting the current element into the publication queue, but this element does not have a link to the "Product Example Test" Sitecore Item in any of its properties, because you dynamically set the Item property for the field renderer in the code.

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

+4
source

Another approach would be to create a Product Example content element in the ProductPage section as a sub-item. In publishing options, you can use public subitems that will publish all the content you want. But the problem is that if you want certain content to be shared in several places, this will not work. Maras answer is the best solution.

+1
source

Source: https://habr.com/ru/post/1498122/


All Articles