Getting started with DD4T 1.31, ASP.NET MVC4 and SDL Tridion 2013

As I noted in my previous post, DD4T has a new version out. To follow up, this post is a step by step guide to getting started with DD4T 1.31, ASP.NET MVC4 and SDL Tridion 2013. The tutorial is the basics to get you up and running, there are plenty of more advanced topics covered in others' blog posts.

This guide assumes you have a working Tridion 2013 install set up and ready to go with some sort of BluePrint, publishing and a Schema called General.

Let's get started.

  1. The new Visual Studio template can be downloaded from the Google Code project.
  2. Once you have installed that on your system, open Visual Studio 2012 or 2013 and you will find a new template under the Visual C# grouping called “DD4T MVC4 Web Application”. Enter the details as you normally would with a new project.
  3. Here's what you'll see in your new project. If you've used a previous template you'll notice this one only uses a single project. solution
  4. The template is pre-configured for Tridion 2013 but you can easily adjust it to work with SDL Tridion 2011 Sp1 by changing the provider package that is included and updating the “using” statement in the DD4TNinjectModule class.
  5. This version of the template has much more in NuGet (hence it is a much smaller download). So you need to install the dependencies from there before it will build successfully. You can either install these one by one (see packages.config for a list) or if you have NuGet 2.7, enable package restore and have them automatically downloaded on build.
    Downloading NuGet Packages
  6. Once you’ve got your project set up, it’s time to put the Tridion Content Delivery in place. Now, this can get a bit fiddly with different Java versions. If you've got 64 bit Java, you'll need 64 bit DLLs and you'll need to run under 64 bit IIS. Copy the DLLs from the roles/api/dotNet/on your installation media. If you want to run under IIS Express and have 32 bit Java, use the 32 bit ones. If you’re running under 64 bit Java and IIS, I recommend using the 64 bit. If you want you can get IIS Express to run as 64 bit by adding a registry key.
  7. If you are running on a machine that has Content Delivery installed you can skip this step. If not, copy in a Content Delivery lib and a config folder into the bin directory of the application. content delivery
  8. Open the cd_storage_conf.xml file and configure this to retrieve Pages, Binaries and Component Presentations from the Content Delivery database for your website Publication or all Publications (if you’re only using DD4T and have many languages). You can see an example here:
  9. Now it’s time to set up Tridion. First, configure your cd_storage_conf.xml on your Deployer server in the same way you did the one on the Content Delivery machine then restart the Deployer service or website.
  10. Next, install the DD4T Template Building Blocks on your CM server.
  11. In the Tridion Content Management Explorer, create a Metadata schema called Page/Component Template metadata with a single field with the XML name “view”
  12. In Template Builder, create a Page Template called "Full Width" using the DD4T Template Building Blocks “Generate dynamic page” and “Publish binaries for page”. Leave the file extension as “html”.
    Page Template TBBs
  13. Add the Metadata Schema to the Page Template called Full Width and set the view field to FullWidth (this matches a view in the template solution)
    Metadata Schema
  14. Create a Component Template using the DD4T Template Building Blocks “Generate dynamic component” and “Publish binaries for component”
    CT TBBs
  15. Add the Metadata Schema to the Component Template called General and set the view field to General (this matches a view in the template solution)
  16. Open the Component Template and add the General Schema to the Linked Schemas.
  17. Create a Page with the file name of “index” using the Full Width Page Template in your root Structure Group
  18. Publish your page.
  19. Set the DD4T.PublicationId in your web.config to the value of your web publication’s item ID.
  20. Run your solution. You should see a simple page with the title of the page from Tridion.
  21. Create a Component using the General Schema and add it to the Page using the General Component Template
  22. Publish the page again
  23. Refresh your page.
  24. You should see the fields of your Component listed out.
    up and running
  25. To see how these work, have a look at the Views folder.

I hope this step by step guide has been helpful, leave a comment if you get stuck with anything.

Want to get involved in DD4T? Join the Google Group.

Any questions?

If you need more information or have any questions just get in touch and we'd be happy to answer them for you.