Hi please see the picture below, so that I can tell you the requirement.

enter image description here

Now, I have a requirement as, if I see page-1 there is content on this page which is coming from following renderings: Header, Footer, Left content 1, Left Content 2 and Right Content.

If I see page-2, there is content coming from the following renderings: Header, Footer, Left Content, Right Content 1 and Right Content 2.

For Client in page 1 the renderings "Left Content 1" and "Left Content 2" has important data which he wants through API so that he can use this data to another external website/system.

Similarly for page-2 "Right Content 1" and "Right Content 2" has important data for him.

He doesn't want the HTML for these renderings. He wants actual data used through Sitecore fields, whether single line text or rich text or any other field type. Now, what approach should I follow to provide him the data of the renderings?

In future different pages may have different renderings and their data source items may have different fields.

What I thought is: Approach One: Get page item for which client wants the data and identify the renderings (I can use a placeholder to identify which rendering is responsible for showing the data in this section of the page) which are responsible for data show. Get data source item from the rendering and get all the fields except standard fields then serialize the data and send back in response. (But this approach may get performance testing failed)

Approach Two: Identify all the possible rendering for all the pages, Get rendering's data source item and index fields(I will provide the restriction like only these fields will be indexed) for those rendering data source I will create index by rendering name so that I can get that index with rendering name (in Azure, I am using Azure for indexing). Now when the client asks me the page data, I will get that page item and check the responsible renderings and get the index with the rendering name and fetch the data for their data source items and return the serialized data.

Any other approach which is optimized will be much appreciated.

The client just knows the page name so he will provide us the page name and he should get the data for the page.

  • Does this site use SXA? – nickwesselman Jun 20 '19 at 15:27
  • Nope, it is not using SXA. This is based on Sitecore 8.2 – Prashant Tomar Jun 20 '19 at 15:31

You can create components and use the experience editor to add them.

My approach would be as follows

First Component (Right side)

Create a component named ContentSpot. This component has a datasource pointing to an item that has the data.

For performance, you can cache the rendering and use the vary by data. Moreover, you can use indexing to pull data from the index. Then, you would not need to have a datasource on the item. So, at rendering time, it will call the index provider and push the result to the rendering.

Second Component (Left side)

Create a component named DynamicContentSpot. This component is responsible to display data based on the result from the API. If I am not mistaken, the component would be of type Controller Rendering.

To make it more generic, this component can have some properties to let you know which API is configured. In other words, the same component can be used to retrieve data from different endpoint. Note that you can also not provide the API directly on the component but just an attribute which can be used to know which API to call.

Experience Editor

Using the experience editor, you can add those components on the page based on your layout placeholders. Using the rendering properties, you can add custom attributes which you can retrieve when rendering the markup on the page.

Note, for caching, you would use vary by data on the renderings (components)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.