Skip to main content

Posts

DD4T: Customizing RenderComponentPresentation

Sometime when we work with Component presentation, we might come up with the scenario to have customized RenderComponentPresentation, when we deal with Area/View or splitting view into more organized structure. We can fetch and send the area from the Template. Currently DD4T doesn’t allow injecting the ComponentPresentationRenderer, instead it allows us to write our own renderer and call it along with RenderComponentPresentation as below The custom ComponentPresenationRenderer can be created based on the scenario, so when we use the area, we could have the custom ComponentPresentation as below SDL Reference implementation, customized Renderer beautifully and implemented the Renderor to use Area view concept.

Navigation in DD4T

There always been a question on What is the best approach for building navigation with DD4T and ASP.NET MVC? Answer is: There is TridionSiteMapProvider as part of the DD4T.Mvc project, which can be used out of the box. The  DD4T.Examples.Templates project also have a example on how Sitemap can be generated from the template ( TBB ) Many organization will have different kinds of navigation structure, It can be from very simple structure or it can be a heavily complex in nature. In this article you can see how the default SitemapProvider can be used and how we could customize to achieve complex Navigations like Megamenu or similar using TridionSiteMapProvider. Setting up the default TridionSiteMapProvider The only configuration you would need to do in web.config is set the your default sitemap provider is as below. <system.web> <siteMap defaultProvider= "TridionSiteMapProvider" enabled= "true" > <providers> <clear/> ...

What is DD4T

Well, It's the high time to think about DD4T. What is DD4T? What makes more easier to the developer and Editor to talk about DD4T.!!  DD4T is a framework that developed by Tridion veterans. The framework makes it easier for Tridion developers to develop, deploy and maintain a project. The basic building blocks of Tridion  like, schema, components, template etc. are still remain the same as below. So what changes, if you look at the below diagram, you could see the different between both So, the whole logic goes to the web server, CMS just plays the role of generating the pages and delivering it to the Broker, no Template logic or HTML in CMS any more. DD4T solves the problem by making sure the pages and content are published to the broker as data, without any HTML rendering. If we summarize the diagram. 1) The role of editor and visitor are normal, and that is the main aspect of DD4T architecture. 2) Everything is published to the broker database. ...

Dynamic Publication Resolving in DD4T

DD4T is a great framework which would give you everything in place what you basically needed. Here we will see how we could resolve the publication based on the URL,  when we work with multiple publications accessing same web site, our DD4T would need to query dynamically to different publications. Many times it can be based on URL, based on the domain or language we could resolve the publication. It’s obviously up to us how we implement it. By default the DD4T framework queries the publication that we have mapped in the key: <add key="DD4T.PublicationId" value="7" /> or keep it 0 to query all publications We can make it dynamic simply by implementing the IPublicationResolver class Step 1: To resolve publication dynamically, we can write a class that implement DD4T.ContentModel.Contracts.Resolvers.IPublicationResolver namespace Indivirtual.DD4T.Mvc.Resolver { public class SitePublicationResolver : IPublicationResolver { ...

ASP.MVC in Umbraco 6

Umbraco 6 brings new lots of improvements for developers, new datalayer, new API’s and complete support for Asp.net MVC 4. This means developers will have greater control, simpler code and higher productivity when developing with Umbraco. As the umbraco blog says, in Umbraco 6 we have: MVC support,  Native Razor support Strongly typed views   Building custom controllers Whole new shiny API Customizing routes. and many more.. Download the latest version 6.0.0. from http://umbraco.codeplex.com/releases . Create a blank MVC4 Application , and add the downloaded files to the newly created website. so that it will make the debugging easier. OR run NuGet Package Manager Command :  PM> Install-Package UmbracoCms Now we can enable the mvc in ~/config/umbracoSettings.config  <defaultRenderingEngine>Mvc</defaultRenderingEngine> by default it will be web forms change it to Mvc. Add another blank MVC4 project to the exist...

pjax with MVC, and form post like pjax

Last weekend I was working on a interesting project, and came across an interesting JavaScript library called pjax. More information on pjax: https://github.com/defunkt/jquery-pjax/ http://pjax.heroku.com/ pjax loads HTML from your server into the current page without a full reload. It's ajax with real permalinks, page titles, and a working back button that fully degrades, It just enhances the browsing experience. I just loved the way we could use it with MVC; Below code sample explains how we could use the same with MVC. Clientside code would look as below: Since the Form post is not handled with pjax, we can do a work around as below. Updated _ViewStart.cshtml as below: @{ if (Request.Headers["X-PJAX"] != null || Request.Headers["AJAX-FORM"]!=null) { Layout = "~/Views/Shared/_PjaxLayout.cshtml"; } else { Layout = "~/Views/Shared/_Layout.cshtml"; } } _PjaxLayout.cshtml ...

Why not to have a static const in c#

This is just a thought, that I was thinking why can't we have a constant with static in C#, and the answer is 'NO'; That we cannot have a static constant; e.g: I created a class as below: public class Constants1 { public const string Const1 = "Hello"; public const string Const2 = "World"; public static string Static1 = "Hello Static"; } When we compile the program into IL, the C# compiler does a magic in IL, that the constants converts into static literals, of course it has to, that's why we are able to access the constants as Constants1.Const1