We are using DXA 1.7 and would like to populate the components dynamically on a page based on the condition. On a tridion page, what needs to be added (for dynamic CT) and when the dynamic logic need to be populated for a page load.
You can use the GetEnityModel using ContentProvider.GetEntityModel (HERE). An sample implementation is available in the test namespace HERE. Per Rick's comments, it has been introduced in 1.2.
You can also use the DD4T API to retrieve the component presentation directly from the Broker. You can try to use the GetComponentPresentation. For your conditions to retrieve the template and components, you can use Broker query directly. Complete documentation of the broker query is available HERE.
You will have to mark the component template as dynamic in the CM side and publish it to the broker. You can also use dynamic assembly in the component template, if you would like to have a hybrid behavior.
I can only provide a generic answer since your question does not contain specific scenarios or approaches that you have already evaluated.
1Do we need to load the dynamic content while building the page model? Since we will not have component presentation on the page, when should invoke the GetComponentPresentation?– SikarwarMar 13, 2019 at 0:54
I don’t get the remark about DXA 1.7 and not having access to ContentProvider.GetEntityModel; this method is available since DXA 1.2. Mar 13, 2019 at 18:45
Yes, I see its available.– SikarwarMar 13, 2019 at 20:29
@RickPannekoek, I have not used it in the earlier versions and I did not go back and check its availability from DXA 1.2. I have updated the information. Thanks for the feedback, as always.– ShivaMar 13, 2019 at 23:11
@Sikarwar, If you are looking for code snippets, I suggest you update your question with relevant information and the community will definitely try to do the best to help out. Cheers.– ShivaMar 13, 2019 at 23:12