I need to write .net application using DD4T and Tridion 9. Please suggest the steps that I can follow ?
-
1Hi Sikarwar. That's a pretty vague question; do you have a working content manager with publishing setup? If not, I'd start there. DD4T is a delivery framework that you'll use to publish content as JSON, and then consume that same content on the delivery side - but you can worry about that once publishing is working. I'd recommend going through the Sites 9 documentation (docs.sdl.com/LiveContent/content/en-US/SDL%20Tridion%20Sites-v1) and then the DD4T docs later on, but again - if you ask a more specific question you might have more luck.– Josh HebbCommented Dec 10, 2019 at 4:12
-
Thanks. When I use this code to render the template , @Html.RenderComponentPresentationsByView("Article"), I get this error - "Controller was not configured in component template metadata or in application settings. Unable to Render component presentation."– SikarwarCommented Dec 10, 2019 at 5:07
-
@JoshHebb Yes, we do have working Tridion 9 publishing setup.– SikarwarCommented Dec 10, 2019 at 5:08
-
I am able to run the DD4T 2.0 application against Tridion 2013, I need to run the same against Tridion 9. Please suggest, what all config changes I need to make?– SikarwarCommented Dec 10, 2019 at 5:53
-
@Sikarwar - Reading through the comments, it sounds like your real issue is that you're having problems rendering 'Article' component presentations. Can you update the question please?– Jonathan WilliamsCommented Jan 9, 2020 at 8:46
Add a comment
|
1 Answer
If you use one of the Html.RenderXXX methods in DD4T, the component presentations will be rendered with a controller and action. You need to create this controller first, by extending the DD4T.Mvc.Controller.ModelControllerBase class, like this:
public ComponentPresentationController : ModelControllerBase
{
public ComponentPresentationController(IPageFactory pageFactory, IComponentPresentationFactory componentPresentationFactory, ILogger logger, IDD4TConfiguration dd4tConfiguration, IViewModelFactory viewModelFactory) :
: base (pageFactory, componentPresentationFactory, logger, dd4tConfiguration, viewModelFactory)
{
}
}
Next, you need to tell DD4T that you want to use this controller to render component presentations. You do this by adding the following to your Web.config:
<add key="DD4T.ComponentPresentationController" value="Component" />
<add key="DD4T.ComponentPresentationAction" value="ComponentModel" />