So I knew the uQuery/uComponents got rolled into Umbraco around Umbraco 4.7. But we have some old uQuery calls that we are using that needs updated or changed, because our we have had a broken Macro for a while that we need to fix now.
Below is our code, can anyone help us figure out what the issue is? I took out the using uComponents reference a while back to try to see if that fixed it, but of course I did not see that as working. Any help is greatly appreciated.
@using umbraco;
@using umbraco.MacroEngines
@inherits umbraco.MacroEngines.DynamicNode
@inherits umbraco.MacroEngines.DynamicNodeContext
@using DWTBlog;
@{
var baseNode = @Model.AncestorOrSelf("DWTBlogLanding");
var newNode = uQuery.GetRootNode().GetDescendantNodes().Where(x => x.HasProperty("alternateAuthor") && x.NodeTypeAlias == "ScienceResearchUpdatesPost").OrderBy(x => umbraco.BusinessLogic.User.GetUser(x.GetProperty<int>("alternateAuthor")).Name);
@*
var newNode = @n.Children.Where("\"alternateAuthor\" != null && NodeTypeAlias == \"ScienceResearchUpdatesPost\"").OrderBy(x => umbraco.BusinessLogic.User.GetUser(x.GetProperty<int>("alternateAuthor")).Name);
*@
string altAuthorList = "";
<h3>Authors</h3>
<ul>
@foreach(var node in newNode)
{
var user = umbraco.BusinessLogic.User.GetUser(node.GetProperty<int>("alternateAuthor"));
if (altAuthorList != user.Name)
{
var numOfPosts = NumberOfBlogsByAlternateAuthor(newNode, node.GetProperty<int>("alternateAuthor"));
if (numOfPosts > 0)
{
if(user.Name == "Administrator" || @node.CreatorName == "Administrator"){
}
else{
<li><a href="@[email protected]&page=1">@user.Name (@numOfPosts)</a></li>
}
}
else
{
@*<li>@node.CreatorName (@numOfPosts)</li>*@
}
}
altAuthorList = user.Name;
}
</ul>
}
@functions{
public static int NumberOfBlogsByAlternateAuthor(IEnumerable<umbraco.NodeFactory.Node> nodes, int alternateAuthorId)
{
var nodeList = new List<umbraco.NodeFactory.Node>();
foreach (var node in nodes)
{
if (node.GetProperty<int>("alternateAuthor") == alternateAuthorId)
{
nodeList.Add(node);
}
}
return nodeList.Count;
}
public static IEnumerable<umbraco.NodeFactory.Node> GetListOfNodes(IEnumerable<umbraco.NodeFactory.Node> nodes, string category)
{
var myNodeList = new List<umbraco.NodeFactory.Node>();
foreach (var node in nodes)
{
var myCategories = node.GetProperty("dwtBlogCategories").Value;
if (!String.IsNullOrWhiteSpace(myCategories))
{
var myCategoryList = new List<string>(myCategories.Split(','));
if (myCategoryList.Any(x => x == category))
{
myNodeList.Add(node);
}
}
}
return myNodeList;
}
}
We are using uComponents 5.1 on our site and we have a test site of uComponents 5.0 on it and this code it working. Is there an issue with 5.1 that caused our issue? We are also using Umbraco 4.9
Old uQuery need help with syntax changes
So I knew the uQuery/uComponents got rolled into Umbraco around Umbraco 4.7. But we have some old uQuery calls that we are using that needs updated or changed, because our we have had a broken Macro for a while that we need to fix now.
Below is our code, can anyone help us figure out what the issue is? I took out the using uComponents reference a while back to try to see if that fixed it, but of course I did not see that as working. Any help is greatly appreciated.
We are using uComponents 5.1 on our site and we have a test site of uComponents 5.0 on it and this code it working. Is there an issue with 5.1 that caused our issue? We are also using Umbraco 4.9
is working on a reply...