Skip to main content

Posts

A DD4T.net Implementation - Rendering One Component Presentation Only

DD4T 1.3 comes with a few Html extension methods that allow us to render Component Presentation inside a Page Razor view using different ways of filtering through the list of ComponentPresentations on the IPage object: RenderComponentPresentations() -- renders all ComponentPresentations on the page; RenderComponentPresentationsBySchema() -- renders only ComponentPresentations whose Component is based on a given Schema title or TcmUri; RenderComponentPresetnationsByView() -- renders only ComponentPresentations whose ComponentTemplate uses a given view name or has a given TcmUri; There is however, no helper method that allows the rendering of just a simple plain ComponentPresentation, yet sometimes that is exactly what I would need. Below is one such Html extension method that calls the rendering of only the given ComponentPresentation object: public static MvcHtmlString RenderComponentPresentation ( this HtmlHelper htmlHelper, IComponentPresentation cp) { if ...

A DD4T.net Implementation - Custom View Locations

The entire need to have custom view locations started when I implemented my Component controllers as separate classes. By default DD4T .net comes (or expects) one ComponentController class. In the Component Template metadata, we can specify the controller, action and view names to execute and use when DD4T renders a Component Presentation on this Component Template. Since I have several Component controllers, for the sake of clarity and separation, I implemented several controller classes -- one for each Component controller I have. For example, I have a DeviceController that renders Component Presentations based on Schema Device . DeviceController defines a simple Index method that is mapped from the Component Template metadata. public class DeviceController : MyControllerBase { public ActionResult Index ( int? publication, int? component, string view) { // code goes here } } The moment I executed my code, I got ni...

A DD4T.net Implementation - Little Bit of Linking

In order to resolve links, the Linking API must be invoked on the Content Delivery server, when the page is being quested. This is also called frying. This ensures that links are always displayed only if the target page is available (i.e. published). In DD4T, when we resolve a Component link, we call one of the ResolveLink methods of the ILinkFactory factory. public interface ILinkFactory { string ResolveLink ( string componentUri); string ResolveLink ( string sourcePageUri, string componentUri, string excludeComponentTemplateUri); ICacheAgent CacheAgent { get ; set ; } ILinkProvider LinkProvider { get ; set ; } } Since we are using strongly-typed models, it means we can easily include this logic in the model itself. This means we can provide a lazy loaded property on the ModelBase class that calls the ILinkFactory.ResolveLink method using the Id  property of the model. public class ModelBase : IComparable<ModelBase> { ...

A DD4T.net Implementation - Making URLs Case Insensitive

URLs in DD4T .net v1.3x are case sensitive. The issue is more of an annoyance than anything because Tridion Content Delivery provides APIs that perform findByUrl in a case-insensitive way. However, that doesn't help us because the default TridionPageProvider  that comes with DD4T .net uses the PageURLCriteria , which case-sensitive. My solution is to extend the TridionPageProvider and override the GetContentByUrl method. In my code I'm using the PageMetaFactory.GetMetaByUrl method, which is case-insensitive. public class MyPageProvider : TridionPageProvider, IPageProvider, IProvider { public new string GetContentByUrl ( string url) { string content = string .Empty; PageMetaFactory factory = new PageMetaFactory(PublicationId); IPageMeta pageMeta = factory.GetMetaByUrl(PublicationId, url); if (pageMeta != null ) { TcmUri tcmUri = new TcmUri(pageMeta.PublicationId, pageMeta.Id, 64 , 0 ); co...

SDL Web 8 - The "Discovery" Microservice

One of the microservices I was describing in my post  Content Delivery Microservices  is the Discovery Service. This post describes what the service does and provide a step-by-step installation guide. The Discovery service is a new addition to the set of functionality in Tridion. It is a REST service that provides information about the capabilities of a given content delivery environment. A capability represents a Content Delivery module that is exposed itself as a REST service (i.e. the other CD Microservices of SDL Web 8). The Discovery service knows about each capability in a given environment and exposes this information in its methods. For example, if a content delivery environment has capabilities Deployer and Dynamic Content , the Discovery service will provide the calling client the information about their endpoints, such that other systems discover what capabilities are available in a given environment, and what are their endpoints, so that they can communicate...

SDL Web 8 - Content Delivery Microservices

Among the new features in SDL Web 8 there are the Content Delivery Microservices, namely: Audience Manager Content Deployer Contextual Image Delivery Discovery Service Dynamic Content Dynamic Linking Profiling and Personalization Metadata Query Taxonomy User Generated Content These microservices make up the Content Interaction Services and they expose the existing Content Delivery in-process APIs as RESTful services. They provide the server-side component in a Services-Oriented Architecture and act as data layer between the the web client and the Content Delivery Storage Layer. According to the SDL marketing, these microservices: Simplify upgrades, thus offering shorter time to value Modernize architecture, offering better separation between the web application and Tridion APIs Offer more flexibility with less downtime and improved scalability Improve quality, being self-running, contained and having less dependencies In technical words, these microservices ...

A DD4T.net Implementation - Rendering Only a Partial for AJAX

Following up on a previous post AJAX Component Controller , I’m going to present in this blog entry a way of rendering not only a Dynamic Component Presentation (DCP) to display its entire view, but also a way to render only a PartialView  in this DCP. The premise of the post is that sometimes we need to request minor updates to a page. These updates can be in the form of just a DCP on the page to be rendered in some AJAX architecture. However, sometimes, even rendering an entire DCP is too much. We then need the granularity to only display/update part of the DCP output. Enter the PartialView rendering. Typically an MVC .net application uses views that in turn include other smaller views, called PartialViews in order to abstract commonly used layout structures and facilitate reuse. In my situation, I had to show a section of dynamically retrieved items as part of my Device view. Since my Component view contains several such sections, it would not make sense to render the entire...