Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When running Dialogue as a seperate node in the root from the reset of the site, it doesnt run (with fix) #100

Open
JohnBergman opened this issue Apr 15, 2017 · 0 comments

Comments

@JohnBergman
Copy link

JohnBergman commented Apr 15, 2017

  • Content Node
    +Dialog Global Node

When you have this situation, some of the queries don't locate the from node. Here is the fix for that in case anyone else runs into this:

Inside ContextHelper.Cs, the EnsureCorrectCultur() method needs to build the xpath string using the constant as follows

var homeNode = helper.TypedContentAtXPath("//root//"+ AppConstants.DocTypeForumRoot).FirstOrDefault();

Inside Dialog.cs, the Settings() method at the bottom should read like this so that it also looks at all of the nodes in the root, and will choose the first one (so be careful).

public static upventurSettings Settings()
{
  if (!HttpContext.Current.Items.Contains(AppConstants.SiteSettingsKey))
  {
    var currentPage = AppHelpers.CurrentPage();
    if (currentPage != null)
    {
      var forumNode = currentPage.AncestorOrSelf(AppConstants.DocTypeForumRoot);
      if (forumNode == null)
      {
        // Only do this is if we can't find the forum normally
        forumNode = currentPage.DescendantOrSelf(AppConstants.DocTypeForumRoot);
        if(forumNode==null)
        {
          var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
          forumNode = umbracoHelper.TypedContentAtRoot().Where(x => x.IsDocumentType(AppConstants.DocTypeForumRoot)).FirstOrDefault();
        }
      }
      HttpContext.Current.Items.Add(AppConstants.SiteSettingsKey, Settings(forumNode));
    }
  }
  return HttpContext.Current.Items[AppConstants.SiteSettingsKey] as upventurSettings;
}

}

The key change is this, which examines the list of root nodes for the forum's main node.

        // Only do this is if we can't find the forum normally
        forumNode = currentPage.DescendantOrSelf(AppConstants.DocTypeForumRoot);
        if(forumNode==null)
        {
          var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
          forumNode = umbracoHelper.TypedContentAtRoot().Where(x => x.IsDocumentType(AppConstants.DocTypeForumRoot)).FirstOrDefault();
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant