0

I am trying to read PublicationTarget Title as explained in the following link https://www.curlette.com/?p=1038

using below code snippet

    @{
var engine = TridionHelper.Engine;
var publishContext = engine.PublishingContext;
var pubTargetTitle = publishContext.PublicationTarget.Title;
}

But I am getting null exception as I am getting PublicationTarget null. We are using SDL Web 8.5

Can you please help me to troubleshoot the issue?

2
  • Prasanna , Are you using Topology setup for publishing target or you using Legecy Publishing Target. – Anand NS May 3 at 11:38
  • Hi Anand, Thank you for your quick response, Yes I am using Topology setup – Prasanna K Gollamudi May 3 at 12:50
2

publishContext.PublicationTarget.Title; is not working with razor , you can use Engine.PublishingContext.TargetType and see if you can get the target , if not create a .net Code and use it on your Component Template

refer to this link for mofre details.

3
  • Thank you Anand, It worked To read Title we need to use Engine.PublishingContext.TargetType.Title – Prasanna K Gollamudi May 3 at 13:43
  • Happy it worked .You used the razor template. – Anand NS May 3 at 13:48
  • Yes using razor mediator template – Prasanna K Gollamudi May 8 at 18:28

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.