2

(Apologies if this is a naff question, but I am pretty new to DD4T)

I am seeing some unexpected behavious in DD4T. We need to be able to retrieve a component, including the full URI for our client app.

I have a URI returned by Tridion.ContentDelivery.DynamicContent.Query

tcm:163-193997-16

and the following code returns a component presentation:

IComponentPresentation cp = _componentPresentationFactory.GetComponentPresentation(uri);

But when I go and inspect the cp.Component object, I can only see ID field as:

tcm:163-193997

I have also looked in the DD4T source on Github, and there is no URI property. The Component class inherits from RepositoryLocalItem, but that seems to be a Java object.

Is there a way to get the URI from the returned DD4T component?

Thanks for your help.

EDIT We are using Tridion.ContentDelivery.DynamicContent.Query functionality to search for components based on KeywordCriteria. But the user can select and search multiple times from the UI. Each search result URI is then used to retrieve the associated component via DD4T. We need to be able to filter out the results of previous searches, so that we only retrieve DD4T components for new found items. Problem is that Tridion.ContentDelivery.DynamicContent.Query returns full URIs, and DD4T only returns component IDs (without '-16'). So we cannot do a comparison between the two to identify previously returned components (without nasty string manipulation). Hope that clarifies it.

  • It's not quite clear what you were expecting, can you update your question with more clarity? If you were expecting the '-16' on the end, this is just because the end part refers to the Item type, 16 is the Item type for a component and it is very common to see it dropped. It's essentially the default. The Content Manager itself doesn't use them much. – David Forster Nov 1 '16 at 18:41
2

Both versions of that URI are valid.

The item type part of a TCM URI is optional for Components. The default behavior is not to include it when the URI is for a Component (so tcm:163-193997 would be what you would normally get from the CM, CME, etc.). But again, it's equally valid with the -16 at the end.

In your case, since you want to compare it later, I would suggest simply storing the version of the URI that do not have the -16 at the end. Or the other way around -- whatever is the least amount of effort for you.

  • Thanks for the reply @peter. I did end up storing the full URI client-side because I could find no other solution. Looks like that is the ONLY solution. Seems inconsistent approach that DD4T and Query cannot share a common component identifier. – maurocam Nov 2 '16 at 12:25
  • I agree, it's not great that it's inconsistent. – Peter Kjaer Nov 2 '16 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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