3

In earlier versions of the framework, default controllers and actions were configured with

<add key="Controller" value="TridionComponent"/>
<add key="Action" value="Component"/>

as blogged by Albert Romkes

In a more recent post by Katarina Stojanovski the advice is to use the following:

<add key="DD4T.ComponentPresentationController" value="Component" />
<add key="DD4T.ComponentPresentationAction" value="ComponentModel" />

I have noticed that in DD4T.Utils.DD4TConfiguration the properties that expose these settings are marked as obsolete. It's not clear why.

So, on the basis that I'm starting a brand new DD4T application and wish to follow current good practice, how should I proceed?

2
  • 1
    Obsolete annotation on ComponentPresentationController and ComponentPresentationAction is wrong. created a ticket for it github.com/dd4t/DD4T.Core/issues/81 Commented May 30, 2016 at 9:29
  • Thanks @SiawashShibani - that helps. So all I need now is some clarity over the differences between the other settings. Commented May 30, 2016 at 9:44

1 Answer 1

2

Web.config Configuration should be:

<add key="DD4T.ComponentPresentationController" value="Component" />
<add key="DD4T.ComponentPresentationAction" value="ComponentModel" />

These values are used as a default for Controller and Action for a components, and could be overwritten by metadata on the Component Template.

For the above configuration the following controller should exist in your app:

 public class ComponentController : ModelControllerBase
    {
        public ComponentController(IPageFactory pageFactory, IComponentPresentationFactory componentPresentationFactory, ILogger logger, IDD4TConfiguration dd4tConfiguration, IViewModelFactory viewModelFactory) : base(pageFactory, componentPresentationFactory, logger, dd4tConfiguration, viewModelFactory)
        {
        }
        public override ActionResult ComponentModel()
        {
            return base.ComponentModel();
        }
    }

The controller above assumes that you're using a strongly typed viewmodels for your application, and your ViewModels are implementing IRenderableViewModel interface.

    [ContentModel("article", true)]
    public class Article : ViewModelBase, IRenderableViewModel
    {

        [TextField]
        public string Heading { get; set; }

        [RenderData]
        public IRenderData RenderData { get; set; }
    }

The logic for RenderData can be found here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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