Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • wayne nixon 12 posts 32 karma points
    Jan 31, 2014 @ 23:15
    wayne nixon
    0

    Error loading MacroEngine script (file: LawyerProfileView.cshtml)

    Working on site i been handed and suddnely a couple of macros have started playing up. Macro was working fine now suddenly this error showed up can anyone help here is the code.

    @using umbraco.MacroEngines
    @inherits umbraco.MacroEngines.DynamicNodeContext
              @functions{
    
                  public void SetPageTitle(string title)
                  {
                      var page = HttpContext.Current.Handler as Page;
                      if (page != null){
                          page.Title = title;
                      }
                  }
    
                  public DynamicNode Homepage
                  {
                      get { 
                          var homepage = Model;
                          while(homepage.NodeTypeAlias != "Homepage"){
                              homepage = homepage.Parent;
                          }
    
                          return homepage;
                      }
                  }
    
                  public HtmlString GetSocialMediaLink(string network, string url, string name)
                  {
                      var socialMediaRepo = Library.NodeById(-1).DescendantsOrSelf("SocialMediaNetworkRepository").First();
                      var socialNetworks = new List<DynamicNode>();
                      if (socialMediaRepo != null)
                      {
                          foreach (var child in socialMediaRepo.Children)
                          {
                              if(child.NodeTypeAlias.ToLower().Equals(network.ToLower())){
                                  var icon = child.HasValue("CssClass") ? String.Format("<i class=\"{0}\"></i>", child.CssClass) : String.Format("<img src=\"/imagegen.ashx?altimage=/images/assets/clear.gif&image={0}\" alt=\"{1}\"/>", child.Icon, child.Name);
                                  return new HtmlString(String.Format("<a target=\"_blank\" rel=\"no-follow\" href=\"{0}\" title=\"{3} on {1}\">{2}</a>", url, child.Name, icon, name) );
                              }
                              socialNetworks.Add(child);
                          }
                      }
                      return new HtmlString("");
                  }
    
              }
    @{
    if (String.IsNullOrEmpty(Request["name"])){
        return;
    }
    var profileId = Request["name"].Replace("-", " ").Replace("/", "");
    
    var lawyersRepository = Library.NodeById(1316);
    var isIntranet = Homepage.Name.IndexOf("intranet", StringComparison.OrdinalIgnoreCase) > -1;
    var nodes = isIntranet ? lawyersRepository.Children.Where("Name.ToLower() = \"" + profileId.ToLower() + "\"") : lawyersRepository.Children.Where("!ProfileIsPrivate && Name.ToLower() = \"" + profileId.ToLower() + "\"");
    if(!nodes.Any()){
        return;
    }
    var node = nodes.First();
    if (node == null || node.NodeTypeAlias != "LawyerRepositoryItem"){
        return;
    }
    
    if (node.ProfileIsPrivate && !isIntranet){
        return;
    }
    
    PageData["PageTitle"] = Model.Name + " - " + node.Name;
    
    SetPageTitle(Model.Name + " - " + node.Name);
    var hasContactInfo = (!String.IsNullOrEmpty(node.TelephoneNumber) || !String.IsNullOrEmpty(node.EmailAddress) || !String.IsNullOrEmpty(node.OfficeLocation));
    <div class="profile">
        <div class="row">
            <div class="span4 profile-content">
                <h1>@node.Name</h1>
                <h3>@node.JobTitle</h3>
                @Html.Raw(node.Biography.ToString())
            </div>
            <div class="span2">
                <div class="profile-picture">
                    @{
                        if (!node.HasValue("ProfilePictureSquare")){
                            <img src="/imagegen.ashx?altimage=/images/assets/clear.gif&[email protected](node.ProfilePicture).umbracoFile" alt="@node.Name" />
                        }
                        else{
                            <img src="/imagegen.ashx?altimage=/images/assets/clear.gif&[email protected](node.ProfilePictureSquare).umbracoFile" alt="@node.Name" />
                        }
                    }
    
                </div>
                <div class="profile-quote">
                    <!--Tesimonial-->
                    @RenderPage("~/macroScripts/Widgets/Widget_RandomTestimonial.cshtml", @node.Id.ToString())
                </div>
            </div>
            @if (hasContactInfo)
            {
                <div class="contact-information">
                    <div class="pull-left contact-details">
                        <h4>@Dictionary.ContactInformationHeading</h4>
                        <dl class="">
                            @{
                if (node.HasValue("TelephoneNumber"))
                {
                                    <dd><strong>@Dictionary.Label_TelephoneShort:</strong>  @node.TelephoneNumber</dd>
                }
                if (node.HasValue("EmailAddress"))
                {
                                    <dd><strong>@Dictionary.Label_EmailShort:</strong> <a href="mailto:@[email protected]">@node.EmailAddress</a></dd>
                }
                if (node.HasValue("OfficeLocation"))
                {
                    var officeNode = Library.NodeById(node.OfficeLocation);
                                    <dd><strong>@Dictionary.Label_Office:</strong> <a href="@officeNode.NiceUrl" title="@officeNode.Name">@officeNode.Name</a></dd>
                }
                            }
                        </dl>
                    </div>
                    <div class="pull-left contact-vcard">
                        <h4>
                            <a href="/[email protected]" title="@Dictionary.DownloadVCard"><i class="t-icon-vcard"></i> <span>@Dictionary.DownloadVCard</span></a></h4>
                    </div>
                </div>
            }
            @{
                var hasSocialMediaUrls = node.HasValue("FacebookUrl") || node.HasValue("TwitterUrl") || node.HasValue("LinkedInUrl") || node.HasValue("YouTubeUrl") || node.HasValue("BlogUrl");
                if (hasSocialMediaUrls)
                {
                    <div class="profile-social-links social-links">
    
                        <ul class="unstyled">
                            <li><strong>@Dictionary.Connect</strong></li>
                            @if (node.HasValue("FacebookUrl"))
                            {
                                <li>@GetSocialMediaLink("facebook", node.FacebookUrl, node.Name)</li>
                            }
                            @if (node.HasValue("TwitterUrl"))
                            {
                                <li>@GetSocialMediaLink("twitter", node.TwitterUrl, node.Name)</li>
                            }
                            @if (node.HasValue("LinkedInUrl"))
                            {
                                <li>@GetSocialMediaLink("linkedin", node.LinkedInUrl, node.Name)</li>
                            }
                            @if (node.HasValue("YouTubeUrl"))
                            {
                                <li>@GetSocialMediaLink("youtube", node.YouTubeUrl, node.Name)</li>
                            }
                            @if (node.HasValue("BlogUrl"))
                            {
                                <li>@GetSocialMediaLink("blogger", node.BlogUrl, node.Name)</li>
                            }
                        </ul>
    
                    </div>
                }
            }
        </div>
        <div class="gold-bar">
            <a href="@Dictionary.SubmitTestimonialLink@Dictionary.SubmitTestimonialLinkParameters.Replace("{Name}", node.Name)">@Dictionary.SubmitTestimonialText</a>
        </div>
    </div>
    }

    i have tried loading from a backup file but the problem persists.

Please Sign in or register to post replies

Write your reply to:

Draft