After upgrading from V9 to V12 I have a transformation that needs help

Daniel Main asked on August 23, 2019 17:08

We have a webpart for our Forums that uses the following Transformation:

<%@ Register Src="~/CMSWebParts/QuitLogix/Forum/ForumPostsLike.ascx" TagName="ForumPostsLike" TagPrefix="cms" %>

<article class="comment">
  <div class="img-block">
    <%# GetUserAvatarImage(Eval("PostUserID"), 200, 0, 0, "") %>
  </div>
  <div class="text-block">
    <div class="heading-holder">
      <h2>
        <%# UserInfoProvider.GetUserInfo(ValidationHelper.GetIntegr(Eval("UserID"), 0)).FirstName %>
        <%# GetForumPostUserFirstName(EvalInteger("PostUserID")) %>
        <%# IsCoach(Eval("PostUserID")) ?  " - <em>" +  ResHelper.GetString("ForumPost.QuitLogixCoach") + "</em>" : "" %>
      </h2>
    </div>
    <p><%# Eval("PostText") %></p>
    <div class="meta-block">
      <div class="posted"><%# ResHelper.GetString("ForumPost.PostedAt") %> <time datetime="<%# DateTimeFormat(Eval<string>("PostTime"), "hh:mm") %>"><%# DateTimeFormat(Eval<string>("PostTime"), "h:mm tt").ToLower() %></time>; <time datetime="<%# DateTimeFormat(Eval<string>("PostTime"), "yyyy-MM-dd") %>"><%# DateTimeFormat(Eval<string>("PostTime"), "MMMM dd, yyyy") %></time></div>
      <cms:ForumPostsLike ID='AddLikeDislike' PostID='<%# EvalInteger("PostId") %>' runat='server' />
    </div>
  </div>
</article>

They give errors like: [TempITemplate.Template]: http://server/CMSVirtualFiles/Transformations/=vg=496cd453-1571-4f9f-9b61-83d04b03651e/QuitLogix.ForumDetails/ForumPostItem.ascx(11): error CS0103: The name 'xxx' does not exist in the current context[TempITemplate.Template] It was working in V9, but after the upgrade it had stopped working and I have narrowed the problems to the following macros: <%# UserInfoProvider.GetUserInfo(ValidationHelper.GetIntegr(Eval("UserID"), 0)).FirstName|(recursive)true %> <%# GetForumPostUserFirstName(EvalInteger("PostUserID")) %> <%# IsCoach(Eval("PostUserID")) ? " - <em>" + ResHelper.GetString("ForumPost.QuitLogixCoach") + "</em>" : "" %> <%# ResHelper.GetString("ForumPost.PostedAt") %> <time datetime="<%# DateTimeFormat(Eval<string>("PostTime"), "hh:mm") %>"><%# DateTimeFormat(Eval<string>("PostTime"), "h:mm tt").ToLower() %></time>; <time datetime="<%# DateTimeFormat(Eval<string>("PostTime"), "yyyy-MM-dd") %>"><%# DateTimeFormat(Eval<string>("PostTime"), "MMMM dd, yyyy") %></time>

I have attempted to find any answers, and even touched base with the company that did the upgrade for us (mostly) but my Google Fu is failing me. I have even replaced the first macro with:

<% CMSContext.Current.GlobalObjects.Users[67855].FirstName; %>

But that provided a similar error: [TempITemplate.Template]: http://server/CMSVirtualFiles/Transformations/=vg=496cd453-1571-4f9f-9b61-83d04b03651e/QuitLogix.ForumDetails/ForumPostItem.ascx(11): error CS0103: The name 'CMSContext' does not exist in the current context

Hopefully I have given enough of an explanation. I know in back end coding the macros work, and they worked before in the transformation, just not sure why they are not working now. It also seems this is the only transformation that is using these macros.

Recent Answers


Dragoljub Ilic answered on August 26, 2019 11:16

Hi Daniel,

I think you are mixing here ASCX and Text/XML transformation macros. If you want to get user in ASCX transformation, you must specify namespace CMS.Membership for UserInfoProvider. Also, in your example, you have an error for ValidationHelper, GetIntegr should be GetInteger. I assume this is only a typo in this code snippet. Here is the code sample that should work in your case: <%# CMS.Membership.UserInfoProvider.GetUserInfo(ValidationHelper.GetInteger(Eval("UserID"), 0)).FirstName %>

Keep in mind that this will do SQL query to database for each comment, so you should think about moving this to custom macro or to the ForumPostsLike.ascx code behind, to implement caching.

Best regards, Dragoljub

0 votesVote for this answer Mark as a Correct answer

Daniel Main answered on August 28, 2019 22:33

Thanks, I was actually able to get this one resolved.

It was actually the Namespace change

`from:
    namespace CMS.Controls
to:
    namespace CMS.DocumentEngine.Web.UI`

in the CMSTransformation.cs file.

or the one you mentioned, I added a call to that in the file as well. everything seems to be working now.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.