2012-11-12 39 views
1

我使用以下代碼來可視化電子郵件中的不同信息。Sitecore Velocity如何構建項目的URL

this.velocityContext.Put("args", args); 
      this.velocityContext.Put("item", args.DataItem); 
      this.velocityContext.Put("processor", args.ProcessorItem); 
      this.velocityContext.Put("user", Context.User); 
      this.velocityContext.Put("history", args.DataItem.State.GetWorkflow().GetHistory(args.DataItem)); 
      this.velocityContext.Put("state", args.DataItem.State.GetWorkflowState()); 
      this.velocityContext.Put("nextState", this.GetNextState(args)); 
      this.velocityContext.Put("site", Context.Site); 
      this.velocityContext.Put("time", DateTime.Now); 
      this.velocityContext.Put("previewUrl",string.Format("Http://{0}/?sc_itemid=%7b{1}%7d&sc_mode=preview",Context.Site.HostName,args.DataItem.ID.Guid)); 

previewUrl的值不起作用。 Context.Site.HostName始終爲空。 有人知道會是什麼原因?或者還有另外一種方法可以建立內容所有者必須審查/批准或拒絕的文章鏈接?

謝謝

+0

什麼是Sitecore.Context.Site?它是內置的默認「網站」上下文嗎?如果需要,您可能需要爲其添加一個hostName屬性。 – techphoria414

+0

我從ExtendedEmailAction獲取了代碼。作爲第三方組件提供的軟件包。由於我的程序集版本不正確,因此我使用了Reflector,並使用Sitecore.NVelocity.dll版本重寫了類庫。在ExtendedEmailAction的代碼中,使用了Context.Site。如果我在我的電子郵件中使用$ site.Name,我會看到這個值:'Shell',這是不正確的:)在這個論壇的另一篇文章中,我找到了使用previewurl的答案。不是通過Context.Site,而是通過DataAccessSettings.Site.HostName – fix105

+0

我引用的鏈接:http://stackoverflow.com/questions/6063558/how-do-i-email-the-original-submitter-using-workflow- in-sitecore – fix105

回答