9

What is the best approach for building navigation with DD4T and ASP.NET MVC?

From Tridion I was thinking to publish the Structure Groups as XML, including URIs for the Pages, and then in the MVC application to parse the XML, resolve the Page Links, and use a sitemap provider (or something like it).

Is there a better way to build the navigation? I found this article for a Sitemap provider, but anything better?http://edspencer.me.uk/2011/09/20/mvc-sitemap-provider-tutorial-2-breadcrumbs/

askedMar 27, 2013 at 7:44
robrtc's user avatar

1 Answer1

9

Rob,

There's aTridionSiteMapProvider as part of the DD4T.Mvc project, which can be used out of the box with the accompanying exampleTBB with generates a sitemap.

Unlike your article though, the sitemap for DD4T generally uses URLs as the editor sees them in Tridion, not controller/action style URLs you normally use with MVC.

The provider is activated by updating your web.config:

<system.web>  <siteMap defaultProvider="TridionSiteMapProvider" enabled="true">    <providers>      <clear/>      <add name="TridionSiteMapProvider" type="DD4T.Mvc.Providers.TridionSiteMapProvider, DD4T.Mvc"/>    </providers>  </siteMap></system.web>

The TBB is an "example" because generating a sitemap typically requires logic specific to what you need in your situation but as with non-DD4T applications, you could generate this from taxonomy or any other mechanism you wish.

Cheers

answeredMar 27, 2013 at 8:29
Neil's user avatar
3
  • An alternative would be to write a SiteMapProvider which reads its input straight from the broker database. It could use taxonomies or structure groups (which are similar to taxonomies on the CD side anyway). In that case, questions like 'which structure groups are part of the navigation', or 'how should I order the items' should be answered in the provider. In the approach that Neil suggests, you typically put that logic in the TBB.CommentedMar 27, 2013 at 9:02
  • I notice that the TBB constructs the URL for the file in navigation at Publish time. CreateUrl(baseUrl, sg.Directory, p.FileName + "." + p.PageTemplate.FileExtension); Why not use a Page URI and dynamic linking?CommentedMar 27, 2013 at 9:30
  • If presentation-server allows it (assuming yes with DD4T, right?), then sure.Nuno Linhares describes that approach in this SO answer.CommentedMar 28, 2013 at 20:13

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.