How do you reference uQuery in Razor files? Seems like the HasProperty stopped working for me.
Do I need to add back in the XSLT extensions for uComponents 5.0? Or is uQuery already in Umbraco 4.9? This is my error after the upgrade to Umbraco 4.9 and uComps 5.0. Does not look like they installed in the XSLT extensions on their own if they are supposed to be in there.
d:\WebSites\dmns.org\macroScripts\634862466553870904_DWTListOfPosts.cshtml(127): error CS1928: 'umbraco.presentation.nodeFactory.Node' does not contain a definition for 'HasProperty' and the best extension method overload 'uComponents.Core.uQueryExtensions.ContentExtensions.HasProperty(umbraco.cms.businesslogic.Content, string)' has some invalid arguments
Error Loading Razor Script (file: DWT List Of Posts) d:\WebSites\dmns.org\macroScripts\DWTListOfPosts.cshtml(127): error CS1928: 'umbraco.presentation.nodeFactory.Node' does not contain a definition for 'HasProperty' and the best extension method overload 'uComponents.Core.uQueryExtensions.ContentExtensions.HasProperty(umbraco.cms.businesslogic.Content, string)' has some invalid arguments at System.Web.Compilation.BuildManager.PostProcessFoundBuildResult(BuildResult result, Boolean keyFromVPP, VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetBuildResultFromCacheInternal(String cacheKey, Boolean keyFromVPP, VirtualPath virtualPath, Int64 hashCode, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultFromCacheInternal(VirtualPath virtualPath, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp) at System.Web.WebPages.VirtualPathFactoryManager.CreateInstance[T](String virtualPath) at System.Web.WebPages.WebPageBase.CreateInstanceFromVirtualPath(String virtualPath, VirtualPathFactoryManager virtualPathFactoryManager) at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage) at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
0.289226703393867
0.000913
umbracoMacro
Loading IMacroEngine script [done]
0.289296265307462
0.000070
umbracoMacro
Error loading MacroEngine script (file: DWTListOfPosts.cshtml, Type: '' d:\WebSites\dmns.org\macroScripts\DWTListOfPosts.cshtml(127): error CS1928: 'umbraco.presentation.nodeFactory.Node' does not contain a definition for 'HasProperty' and the best extension method overload 'uComponents.Core.uQueryExtensions.ContentExtensions.HasProperty(umbraco.cms.businesslogic.Content, string)' has some invalid arguments at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)
0.289357725632727
0.000061
renderMacro
Rendering started (macro: DWT Side Bar Authors, type: 6, cacheRate: 360)
Error Loading Razor Script (file: DWT Side Bar Authors) d:\WebSites\dmns.org\macroScripts\DWTSideBarAuthors.cshtml(55): error CS1928: 'umbraco.presentation.nodeFactory.Node' does not contain a definition for 'GetPropertyAsInt' and the best extension method overload 'uComponents.Core.uQueryExtensions.ContentExtensions.GetPropertyAsInt(umbraco.cms.businesslogic.Content, string)' has some invalid arguments at System.Web.Compilation.BuildManager.PostProcessFoundBuildResult(BuildResult result, Boolean keyFromVPP, VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetBuildResultFromCacheInternal(String cacheKey, Boolean keyFromVPP, VirtualPath virtualPath, Int64 hashCode, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultFromCacheInternal(VirtualPath virtualPath, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp) at System.Web.WebPages.VirtualPathFactoryManager.CreateInstance[T](String virtualPath) at System.Web.WebPages.WebPageBase.CreateInstanceFromVirtualPath(String virtualPath, VirtualPathFactoryManager virtualPathFactoryManager) at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage) at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
0.290141624144968
0.000570
umbracoMacro
Loading IMacroEngine script [done]
0.290201687644659
0.000060
umbracoMacro
Error loading MacroEngine script (file: DWTSideBarAuthors.cshtml, Type: '' d:\WebSites\dmns.org\macroScripts\DWTSideBarAuthors.cshtml(55): error CS1928: 'umbraco.presentation.nodeFactory.Node' does not contain a definition for 'GetPropertyAsInt' and the best extension method overload 'uComponents.Core.uQueryExtensions.ContentExtensions.GetPropertyAsInt(umbraco.cms.businesslogic.Content, string)' has some invalid arguments at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)
0.290252811460675
0.000051
renderMacro
Rendering started (macro: DWT Side Bar Categories, type: 6, cacheRate: 360)
0.290386347985568
0.000134
renderMacro
Macro Content loaded from cache 'DWTSideBarCategories-13321-'.
0.290410932115674
0.000025
renderMacro
Rendering started (macro: DWT Tag Cloud, type: 6, cacheRate: 300)
0.29043607497601
0.000025
umbracoMacro
MacroEngine script added (DWTTagCloud.cshtml)
0.290458424185197
0.000022
umbracoMacro
Loading IMacroEngine script
0.290473230536283
0.000015
umbracoMacro
Error Loading Razor Script (file: DWT Tag Cloud) d:\WebSites\dmns.org\macroScripts\DWTTagCloud.cshtml(29): error CS1928: 'umbraco.presentation.nodeFactory.Node' does not contain a definition for 'HasProperty' and the best extension method overload 'uComponents.Core.uQueryExtensions.ContentExtensions.HasProperty(umbraco.cms.businesslogic.Content, string)' has some invalid arguments at System.Web.Compilation.BuildManager.PostProcessFoundBuildResult(BuildResult result, Boolean keyFromVPP, VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetBuildResultFromCacheInternal(String cacheKey, Boolean keyFromVPP, VirtualPath virtualPath, Int64 hashCode, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultFromCacheInternal(VirtualPath virtualPath, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp) at System.Web.WebPages.VirtualPathFactoryManager.CreateInstance[T](String virtualPath) at System.Web.WebPages.WebPageBase.CreateInstanceFromVirtualPath(String virtualPath, VirtualPathFactoryManager virtualPathFactoryManager) at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage) at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
0.291036151242686
0.000563
umbracoMacro
Loading IMacroEngine script [done]
0.291096773472606
0.000061
umbracoMacro
Error loading MacroEngine script (file: DWTTagCloud.cshtml, Type: '' d:\WebSites\dmns.org\macroScripts\DWTTagCloud.cshtml(29): error CS1928: 'umbraco.presentation.nodeFactory.Node' does not contain a definition for 'HasProperty' and the best extension method overload 'uComponents.Core.uQueryExtensions.ContentExtensions.HasProperty(umbraco.cms.businesslogic.Content, string)' has some invalid arguments at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)
0.291153205225804
0.000056
renderMacro
Rendering started (macro: DWT Side Bar Archives, type: 6, cacheRate: 360)
Error Loading Razor Script (file: DWT Side Bar Archives) d:\WebSites\dmns.org\macroScripts\DWTSideBarArchives.cshtml(45): error CS1928: 'umbraco.presentation.nodeFactory.Node' does not contain a definition for 'GetPropertyAsDateTime' and the best extension method overload 'uComponents.Core.uQueryExtensions.ContentExtensions.GetPropertyAsDateTime(umbraco.cms.businesslogic.Content, string)' has some invalid arguments at System.Web.Compilation.BuildManager.PostProcessFoundBuildResult(BuildResult result, Boolean keyFromVPP, VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetBuildResultFromCacheInternal(String cacheKey, Boolean keyFromVPP, VirtualPath virtualPath, Int64 hashCode, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultFromCacheInternal(VirtualPath virtualPath, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp) at System.Web.WebPages.VirtualPathFactoryManager.CreateInstance[T](String virtualPath) at System.Web.WebPages.WebPageBase.CreateInstanceFromVirtualPath(String virtualPath, VirtualPathFactoryManager virtualPathFactoryManager) at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage) at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
0.291880392619732
0.000558
umbracoMacro
Loading IMacroEngine script [done]
0.291940176754308
0.000060
umbracoMacro
Error loading MacroEngine script (file: DWTSideBarArchives.cshtml, Type: '' d:\WebSites\dmns.org\macroScripts\DWTSideBarArchives.cshtml(45): error CS1928: 'umbraco.presentation.nodeFactory.Node' does not contain a definition for 'GetPropertyAsDateTime' and the best extension method overload 'uComponents.Core.uQueryExtensions.ContentExtensions.GetPropertyAsDateTime(umbraco.cms.businesslogic.Content, string)' has some invalid arguments at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)
I removed the "using uComponents.Core.uQueryExtensions", that did not work. What would be an alternative to my query
Thank for the response. But still got nothing. I added the @using umbraco; and that still did not work. I am still getting the same error. Is there a DLL or something in one of the config files that ABSOLUTELY has to be there for the uQuery stuff to work?
d:\WebSites\dmns.org\macroScripts\634862466553870904_DWTListOfPosts.cshtml(127): error CS1928: 'umbraco.presentation.nodeFactory.Node' does not contain a definition for 'HasProperty' and the best extension method overload 'uComponents.Core.uQueryExtensions.ContentExtensions.HasProperty(umbraco.cms.businesslogic.Content, string)' has some invalid arguments
This is my using list.
@using System.Linq; @using System.Xml.Linq; @using umbraco; @using umbraco.BusinessLogic; @using umbraco.MacroEngines; @inherits umbraco.MacroEngines.DynamicNode @inherits umbraco.MacroEngines.DynamicNodeContext @inherits DynamicNodeContext @using umbraco.cms.businesslogic.datatype @using System.Xml.XPath @using DWTBlog; @using uComponents (Note: tried it without this too.)
For good measure, here is my code I am trying to work with since the upgrade. I have taking out the @using uComponents.Core and added the @using umbraco
@using umbraco
@using System.Linq;
@using System.Xml.Linq;
@using umbraco.BusinessLogic;
@using umbraco.MacroEngines;
@inherits umbraco.MacroEngines.DynamicNode
@inherits umbraco.MacroEngines.DynamicNodeContext
@inherits DynamicNodeContext
@using umbraco.cms.businesslogic.datatype
@using System.Xml.XPath
@using DWTBlog;
@{
IEnumerable<umbraco.presentation.nodeFactory.Node> nodesList = null;
// configuration
var itemsPerPage = String.IsNullOrEmpty(Parameter.ItemsPerPage) ? 3 : int.Parse(Parameter.ItemsPerPage);
var previousLabel = String.IsNullOrEmpty(Parameter.PreviousLabel) ? "Prev" : Parameter.PreviousLabel;
var nextLabel = String.IsNullOrEmpty(Parameter.NextLabel) ? "Next" : Parameter.NextLabel;
var postDateProperty = "dwtBlogPostDate"; // change to "dwtBlogPostDate" for live site
int currentPage = 1;
if (!int.TryParse(HttpContext.Current.Request.QueryString["Page"], out currentPage)) {
currentPage = 1;
}
// paging calculations
currentPage--;
@*// XPATH properties to get prevalues of Categories*@
@*AUTHORS*@
if(!String.IsNullOrEmpty(Request.QueryString["author"])){
nodesList = uQuery.GetRootNode().GetDescendantNodes().Where(x => x.NodeTypeAlias == "ScienceResearchUpdatesPost" && x.CreatorName == Request.QueryString["author"]).OrderByDescending(x => x.CreateDate);
<h3>(hit Author) This many hits for author: @nodesList.Count()</h3>
int skipThisMany = currentPage*itemsPerPage;
int loadThisMany = itemsPerPage;
@PostListings2(nodesList.Skip(skipThisMany).Take(loadThisMany), postDateProperty );
}
@*Alternate Author*@
else if(!String.IsNullOrEmpty(Request.QueryString["altAuthor"])){
nodesList = uQuery.GetRootNode().GetDescendantNodes().Where(x => x.HasProperty("alternateAuthor") && x.NodeTypeAlias == "ScienceResearchUpdatesPost" && umbraco.BusinessLogic.User.GetUser(x.GetPropertyAsInt("alternateAuthor")).Name == Request.QueryString["altAuthor"]).OrderByDescending(x => x.GetPropertyAsDateTime(postDateProperty ));
<h3>This many hits for author @Request.QueryString["altAuthor"]: @nodesList.Count()</h3>
int skipThisMany = currentPage*itemsPerPage;
int loadThisMany = itemsPerPage;
@PostListings2(nodesList.Skip(skipThisMany).Take(loadThisMany), postDateProperty );
}
@*CATEGORIES*@
else if(!String.IsNullOrEmpty(Request.QueryString["category"])){
nodesList = @DWTBlog.ListOfPosts.GetListOfNodes(uQuery.GetRootNode().GetDescendantNodes().Where(x => x.NodeTypeAlias == "ScienceResearchUpdatesPost").OrderByDescending(x => x.GetPropertyAsDateTime(postDateProperty)), Request.QueryString["category"]);
<h3>Articles in category @Request.QueryString["category"]: @nodesList.Count()</h3>
int skipThisMany = currentPage*itemsPerPage;
int loadThisMany = itemsPerPage;
@PostListings2(nodesList.Skip(skipThisMany).Take(loadThisMany), postDateProperty );
}
@*DATES*@
else if(!String.IsNullOrEmpty(Request.QueryString["archive"])){
nodesList = @DWTBlog.ListOfPosts.GetNodesByMonth(uQuery.GetRootNode().GetDescendantNodes().Where(x => x.NodeTypeAlias == "ScienceResearchUpdatesPost").OrderByDescending(x => x.CreateDate), Request.QueryString["archive"]);
int skipThisMany = currentPage*itemsPerPage;
int loadThisMany = itemsPerPage;
@PostListings2(nodesList.Skip(skipThisMany).Take(loadThisMany), postDateProperty );
}
@* Alternate DATES *@
else if(!String.IsNullOrEmpty(Request.QueryString["altArchive"])){
nodesList = GetNodesByAltMonth(uQuery.GetRootNode().GetDescendantNodes().Where(x => x.NodeTypeAlias == "ScienceResearchUpdatesPost" && x.HasProperty(postDateProperty )).OrderByDescending(x => x.GetPropertyAsDateTime(postDateProperty )), Request.QueryString["altArchive"], postDateProperty );
var dateOfSearch = Convert.ToDateTime(@Request.QueryString["altArchive"]);
<h3>@nodesList.Count() article(s) for @dateOfSearch.ToString("MMMM yyyy")</h3>
int skipThisMany = currentPage*itemsPerPage;
int loadThisMany = itemsPerPage;
@PostListings2(nodesList.Skip(skipThisMany).Take(loadThisMany), postDateProperty );
}
@*Tags*@
else if(!String.IsNullOrEmpty(Request.QueryString["tag"])){
nodesList = @DWTBlog.ListOfPosts.GetNodesByTag(uQuery.GetRootNode().GetDescendantNodes().Where(x => x.NodeTypeAlias == "ScienceResearchUpdatesPost").OrderByDescending(x => x.GetPropertyAsDateTime(postDateProperty )), Request.QueryString["tag"]);
<h3>Articles tagged @Request.QueryString["tag"]: @nodesList.Count()</h3>
int skipThisMany = currentPage*itemsPerPage;
int loadThisMany = itemsPerPage;
@PostListings2(nodesList.Skip(skipThisMany).Take(loadThisMany), postDateProperty );
}
@*NOTHING*@
else{
nodesList = uQuery.GetRootNode().GetDescendantNodes().Where(x => x.NodeTypeAlias == "ScienceResearchUpdatesPost").OrderByDescending(x => x.GetPropertyAsDateTime(postDateProperty));
<h3>Number of Articles: @nodesList.Count()</h3>
@* @PostListings(@Model.NodeById(1089).Descendants("ScienceResearchUpdatesPost").OrderBy("CreateDate desc").Skip(currentPage*itemsPerPage).Take(itemsPerPage)); *@
int skipThisMany = currentPage*itemsPerPage;
int loadThisMany = itemsPerPage;
@PostListings2(nodesList.Skip(skipThisMany).Take(loadThisMany), postDateProperty);
}
@*DMNS - ELSE IF HERE? Would this need to be per section?*@
var numberOfItems = nodesList.Count();
var numberOfPages = numberOfItems % itemsPerPage == 0 ? Math.Ceiling((decimal)(numberOfItems / itemsPerPage)) : Math.Ceiling((decimal)(numberOfItems / itemsPerPage))+1;
// pagination
if (nodesList != null)
{
@PaginationHelper(nodesList, itemsPerPage)
}
}
@*Helper method for redirection*@
@helper PostListings2(IEnumerable<umbraco.presentation.nodeFactory.Node> list, string propertyName)
{
var baseNode = @Model.AncestorOrSelf("DWTBlogLanding");
<ul class="dwtPostList">
@foreach(var nodeItem in list){
var postDateString = "";
var postedByString = "";
<li>
<h3>
<a href="http://www.dmns.org@(baseNode.Url)Post/?nid=@(nodeItem.Id)">@nodeItem.Name</a>
</h3>
@if (nodeItem.GetProperty("alternateAuthor") == null){
@* <div class="dwtPosted">Posted @nodeItem.CreateDate by @nodeItem.CreatorName</div> *@
} else if (nodeItem.HasProperty(propertyName)) {
@* var postedDate = @nodeItem.GetPropertyAsDateTime(propertyName);
<div class="dwtPosted">Posted @postedDate.ToString("MM/dd/yyyy") by <a href="@baseNode.Url?altAuthor=@(@umbraco.BusinessLogic.User.GetUser(@nodeItem.GetPropertyAsInt("alternateAuthor")).Name)">@umbraco.BusinessLogic.User.GetUser(@nodeItem.GetPropertyAsInt("alternateAuthor")).Name</a> | <a href="http://www.dmns.org@(baseNode.Url)/Post/[email protected]#disqus_thread">Comments</a></div>
*@
} else {
@*
<div class="dwtPosted">Posted @postedDate.ToString("MM/dd/yyyy") by <a href="@baseNode.Url?altAuthor=@(@umbraco.BusinessLogic.User.GetUser(@nodeItem.GetPropertyAsInt("alternateAuthor")).Name)">@umbraco.BusinessLogic.User.GetUser(@nodeItem.GetPropertyAsInt("alternateAuthor")).Name</a> | <a href="http://www.dmns.org@(baseNode.Url)/Post/[email protected]#disqus_thread">Comments</a></div>
*@
}
<div class="dwtPosted">Posted by </div>
@if(!String.IsNullOrWhiteSpace(@nodeItem.GetProperty("landingPageImage").Value)){
var postImage = Library.MediaById(@nodeItem.GetProperty("landingPageImage").Value);
<div id="mediaHolder"><img src="@postImage.Url" style="padding-top:25px; display:block; width:560px; height:336px;"/></div>
}
@Library.Truncate(Library.StripHtml(@nodeItem.GetProperty("bodyText").Value, "img", "a", "object", "param", "table", "embed", "iframe", "strong", "b", "p"),300)
<div class="dwtBtnHolder">
<a href="http://www.dmns.org/@(baseNode.Url)Post/?nid=@(nodeItem.Id)" class="buyNowBtn">Read More</a>
</div>
@if(@nodeItem.HasProperty("dwtBlogCategories")){
<div class="dwtBlogCatTagContainer">
<div class="dwtPostListCategories">
<span> Categories: </span>
<ul class="dwtPostListCategoriesList">
@{var categories = @nodeItem.GetProperty("dwtBlogCategories").Value.Split(",".ToCharArray());}
@foreach(var c in categories){
<li><a href="@baseNode.Url?category=@c">@c</a></li>
}
</div>
<div class="dwtPostListTags">
<span> Tags: </span>
<ul class="dwtPostListTagsList">
@{var tags = @nodeItem.GetProperty("tags").Value.Split(",".ToCharArray());}
@foreach(var t in tags){
<li><a href="@baseNode.Url?tag=@t">@t</a></li>
}
</ul>
</div>
</div>
}
</li>
}
</ul>
}
@helper PostListings(DynamicNodeList list)
{
var baseNode = @Model.AncestorOrSelf("DWTBlogLanding");
<ul class="dwtPostList">
@foreach(DynamicNode nodeItem in @list){
<li>
<h3>
<a href="http://www.dmns.org/@(baseNode.Url)Post/?nid=@(nodeItem.Id)">@nodeItem.Name</a>
</h3>
<div class="dwtPosted">Posted @nodeItem.CreateDate by @nodeItem.CreatorName</div>
@Library.Truncate(Library.StripHtml(@nodeItem.GetProperty("bodyText").Value, "img", "a", "object", "param", "table", "embed", "iframe", "strong", "b", "p"),300)
<div class="dwtBtnHolder">
<a href="http://www.dmns.org/@(baseNode.Url)Post/?nid=@(nodeItem.Id)" class="buyNowBtn">Read More</a>
</div>
@if(@nodeItem.HasValue("dwtBlogCategories")){
<div class="dwtBlogCatTagContainer">
<div class="dwtPostListCategories">
<span> Categories: </span>
<ul class="dwtPostListCategoriesList">
@{var categories = @nodeItem.GetProperty("dwtBlogCategories").Value.Split(",".ToCharArray());}
@foreach(var c in categories){
<li><a href="@baseNode.Url?category=@c">@c</a></li>
}
</div>
</div>
}
</li>
}
</ul>
}
@helper CategoryList(){
}
@*WILL GET TO THIS LATER*@
@helper PaginationHelper(IEnumerable<umbraco.presentation.nodeFactory.Node> nodes, int itemsPerPage){
var pagesToList = nodes;
var previousLabel = String.IsNullOrEmpty(Parameter.PreviousLabel) ? "Previous" : Parameter.PreviousLabel;
var nextLabel = String.IsNullOrEmpty(Parameter.NextLabel) ? "Next" : Parameter.NextLabel;
// paging calculations
var numberOfItems = pagesToList.Count();
<h3>numberOfItems: @numberOfItems</h3>
int currentPage = 1;
if (!int.TryParse(HttpContext.Current.Request.QueryString["Page"], out currentPage)) {
currentPage = 1;
}
@*DMNS - ELSE IF HERE? Would this need to be per section?*@
currentPage--;
var numberOfPages = numberOfItems % itemsPerPage == 0 ? Math.Floor((decimal)(numberOfItems / itemsPerPage)) : Math.Floor((decimal)(numberOfItems / itemsPerPage)) + 1;
<h3>numberOfPages: @numberOfPages</h3>
<div class="pagingPages">
@{
// Google style paging links
var previousQueryString = "";
if(!String.IsNullOrEmpty(Request.QueryString["author"]))
{
previousQueryString = "?author=" + Request.QueryString["author"];
}
else if(!String.IsNullOrEmpty(Request.QueryString["altAuthor"]))
{
previousQueryString = "?altAuthor=" + Request.QueryString["altAuthor"];
}
else if(!String.IsNullOrEmpty(Request.QueryString["category"]))
{
previousQueryString = "?category=" + Request.QueryString["category"];
}
else if(!String.IsNullOrEmpty(Request.QueryString["archive"]))
{
previousQueryString = "?archive=" + Request.QueryString["archive"];
}
else if(!String.IsNullOrEmpty(Request.QueryString["altArchive"]))
{
previousQueryString = "?altArchive=" + Request.QueryString["altArchive"];
}
else if(!String.IsNullOrEmpty(Request.QueryString["tag"]))
{
previousQueryString = "?tag=" + Request.QueryString["tag"];
}
var pageString = "?page=";
if (!String.IsNullOrEmpty(previousQueryString))
{
pageString = "&page=";
}
if(currentPage > 0) {
<a href="@(previousQueryString)@(pageString)@(currentPage)">« @previousLabel</a>
} else {
<span class="pagingDisabled">« @previousLabel</span>
}
var Pages = Enumerable.Range(1, (int)numberOfPages);
foreach(var number in Pages) {
if(number-1 != currentPage) {
<a href="@(previousQueryString)@(pageString)@number">@number</a>
} else {
<span class="dwtPagingCurrent">@number</span>
}
}
if(currentPage < Pages.Count()-1) {
<a href="@(previousQueryString)@(pageString)@(currentPage+2)">@nextLabel »</a>
}else {
<span class="pagingDisabled">@nextLabel »</span>
}
}
</div>
}
@functions{
public static IEnumerable<umbraco.presentation.nodeFactory.Node> GetNodesByAltMonth(IEnumerable<umbraco.presentation.nodeFactory.Node> nodes, string archiveDate, string propertyName)
{
var date = Convert.ToDateTime(archiveDate);
var nodeList = new List<umbraco.presentation.nodeFactory.Node>();
foreach (var node in nodes)
{
var nodeDate = node.GetPropertyAsDateTime(propertyName);
if (nodeDate.Month == date.Month && nodeDate.Year == date.Year)
{
nodeList.Add(node);
}
}
return nodeList;
}
}
It seems like some of the definitions, for me anyways, don't want to work. I did as you suggested (thanks for that catch. I was unaware of the changes). Now I am getting different error on mulitple ways of getting properties.
It seems like the 'GetPropertyAsDateTime' and 'GetPropertyAsString' and possibly others are causing erros because umbraco.NodeFactory doesn't contain those definitions.
Did something change with the uQuery stuff? Now I am getting
Error occured
d:\WebSites\dmns.org\macroScripts\634865824691844624_DWTListOfPosts.cshtml(298): error CS1061: 'umbraco.NodeFactory.Node' does not contain a definition for 'GetPropertyAsDateTime' and no extension method 'GetPropertyAsDateTime' accepting a first argument of type 'umbraco.NodeFactory.Node' could be found (are you missing a using directive or an assembly reference?)
And in another Controls
Error occured
d:\WebSites\dmns.org\macroScripts\634865827448737268_CrossPromotionUQuery.cshtml(18): error CS1061: 'umbraco.NodeFactory.Node' does not contain a definition for 'GetPropertyAsString' and no extension method 'GetPropertyAsString' accepting a first argument of type 'umbraco.NodeFactory.Node' could be found (are you missing a using directive or an assembly reference?)
OK, I think we have found the issue. In the new uQuery GetPropertyAsString, GetPropertyAsBool, GetPropertyAsDateTime, etc are NOT in the in the Umbraco.Core but WERE in the uComponents.Core. Does not look like the new Umbraco.Core has these properties, and the Umbraco.Legacy.dll does, HOWEVER, we could not access the definitions.
So our solution to our issue with GetPropertyAsDateTime(postDateProperty) is to used the new way that Umbraco.Core's uQuery says to use it as a Generic Type by stating GetProperty<DateTime>(node, "property name") or ours is now GetPropertyAsDateTime(postDateProperty). GetPropertyAsDateTime(postDateProperty) .
Was this intentional? These definitions caused us a LOT of headache until we broke open the DLL's to see what was going on.
So that is the solution
GetPropertyAsDateTime("property name") is now
GetProperty<DateTime>(node, "property name")
We hope this helps someone else who is having the same issues we were having using some older uComponents definitions that will not work in 4.9.
Hopefully this gets documented someplace too. Would be awesome.
Umbraco 4.9 and uQuery
How do you reference uQuery in Razor files? Seems like the HasProperty stopped working for me.
Do I need to add back in the XSLT extensions for uComponents 5.0? Or is uQuery already in Umbraco 4.9? This is my error after the upgrade to Umbraco 4.9 and uComps 5.0. Does not look like they installed in the XSLT extensions on their own if they are supposed to be in there.
d:\WebSites\dmns.org\macroScripts\634862466553870904_DWTListOfPosts.cshtml(127): error CS1928: 'umbraco.presentation.nodeFactory.Node' does not contain a definition for 'HasProperty' and the best extension method overload 'uComponents.Core.uQueryExtensions.ContentExtensions.HasProperty(umbraco.cms.businesslogic.Content, string)' has some invalid arguments
Any suggestions?
Thanks in advance
I am getting this in my stack trace
at System.Web.Compilation.BuildManager.GetBuildResultFromCacheInternal(String cacheKey, Boolean keyFromVPP, VirtualPath virtualPath, Int64 hashCode, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultFromCacheInternal(VirtualPath virtualPath, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp)
at System.Web.WebPages.VirtualPathFactoryManager.CreateInstance[T](String virtualPath)
at System.Web.WebPages.WebPageBase.CreateInstanceFromVirtualPath(String virtualPath, VirtualPathFactoryManager virtualPathFactoryManager)
at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage)
at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
d:\WebSites\dmns.org\macroScripts\DWTListOfPosts.cshtml(127): error CS1928: 'umbraco.presentation.nodeFactory.Node' does not contain a definition for 'HasProperty' and the best extension method overload 'uComponents.Core.uQueryExtensions.ContentExtensions.HasProperty(umbraco.cms.businesslogic.Content, string)' has some invalid arguments
at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)
at System.Web.Compilation.BuildManager.GetBuildResultFromCacheInternal(String cacheKey, Boolean keyFromVPP, VirtualPath virtualPath, Int64 hashCode, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultFromCacheInternal(VirtualPath virtualPath, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp)
at System.Web.WebPages.VirtualPathFactoryManager.CreateInstance[T](String virtualPath)
at System.Web.WebPages.WebPageBase.CreateInstanceFromVirtualPath(String virtualPath, VirtualPathFactoryManager virtualPathFactoryManager)
at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage)
at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
d:\WebSites\dmns.org\macroScripts\DWTSideBarAuthors.cshtml(55): error CS1928: 'umbraco.presentation.nodeFactory.Node' does not contain a definition for 'GetPropertyAsInt' and the best extension method overload 'uComponents.Core.uQueryExtensions.ContentExtensions.GetPropertyAsInt(umbraco.cms.businesslogic.Content, string)' has some invalid arguments
at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)
at System.Web.Compilation.BuildManager.GetBuildResultFromCacheInternal(String cacheKey, Boolean keyFromVPP, VirtualPath virtualPath, Int64 hashCode, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultFromCacheInternal(VirtualPath virtualPath, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp)
at System.Web.WebPages.VirtualPathFactoryManager.CreateInstance[T](String virtualPath)
at System.Web.WebPages.WebPageBase.CreateInstanceFromVirtualPath(String virtualPath, VirtualPathFactoryManager virtualPathFactoryManager)
at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage)
at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
d:\WebSites\dmns.org\macroScripts\DWTTagCloud.cshtml(29): error CS1928: 'umbraco.presentation.nodeFactory.Node' does not contain a definition for 'HasProperty' and the best extension method overload 'uComponents.Core.uQueryExtensions.ContentExtensions.HasProperty(umbraco.cms.businesslogic.Content, string)' has some invalid arguments
at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)
at System.Web.Compilation.BuildManager.GetBuildResultFromCacheInternal(String cacheKey, Boolean keyFromVPP, VirtualPath virtualPath, Int64 hashCode, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultFromCacheInternal(VirtualPath virtualPath, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp)
at System.Web.WebPages.VirtualPathFactoryManager.CreateInstance[T](String virtualPath)
at System.Web.WebPages.WebPageBase.CreateInstanceFromVirtualPath(String virtualPath, VirtualPathFactoryManager virtualPathFactoryManager)
at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage)
at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
d:\WebSites\dmns.org\macroScripts\DWTSideBarArchives.cshtml(45): error CS1928: 'umbraco.presentation.nodeFactory.Node' does not contain a definition for 'GetPropertyAsDateTime' and the best extension method overload 'uComponents.Core.uQueryExtensions.ContentExtensions.GetPropertyAsDateTime(umbraco.cms.businesslogic.Content, string)' has some invalid arguments
at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)
I removed the "using uComponents.Core.uQueryExtensions", that did not work. What would be an alternative to my query
nodesList = uQuery.GetRootNode().GetDescendantNodes().Where(x => x.HasProperty("alternateAuthor") && x.NodeTypeAlias == "ScienceResearchUpdatesPost" && umbraco.BusinessLogic.User.GetUser(x.GetPropertyAsInt("alternateAuthor")).Name == Request.QueryString["altAuthor"]).OrderByDescending(x => x.GetPropertyAsDateTime(postDateProperty ));
Because it is not working. Am I missing something in my Umbraco build? Very frustrated, what is going on?
HI Carlos,
The namespace to reference uQuery (in Umbraco 4.8+ core) is:
Cheers, Lee.
@Lee,
Thank for the response. But still got nothing. I added the @using umbraco; and that still did not work. I am still getting the same error. Is there a DLL or something in one of the config files that ABSOLUTELY has to be there for the uQuery stuff to work?
d:\WebSites\dmns.org\macroScripts\634862466553870904_DWTListOfPosts.cshtml(127): error CS1928: 'umbraco.presentation.nodeFactory.Node' does not contain a definition for 'HasProperty' and the best extension method overload 'uComponents.Core.uQueryExtensions.ContentExtensions.HasProperty(umbraco.cms.businesslogic.Content, string)' has some invalid arguments
This is my using list.
@using System.Linq;
@using System.Xml.Linq;
@using umbraco;
@using umbraco.BusinessLogic;
@using umbraco.MacroEngines;
@inherits umbraco.MacroEngines.DynamicNode
@inherits umbraco.MacroEngines.DynamicNodeContext
@inherits DynamicNodeContext
@using umbraco.cms.businesslogic.datatype
@using System.Xml.XPath
@using DWTBlog;
@using uComponents (Note: tried it without this too.)
For good measure, here is my code I am trying to work with since the upgrade. I have taking out the @using uComponents.Core and added the @using umbraco
Hi Carlos,
I think part of the issue might be that you're referencing the "old" NodeFactory namespace in some areas. Try changing any references to
to just this:
Node
Then add this using statement using the newer NodeFactory namespace (the old version was umbraco.presentation.nodeFactory)
Hope this helps,
Tom
@Tom
It seems like some of the definitions, for me anyways, don't want to work.
I did as you suggested (thanks for that catch. I was unaware of the changes). Now I am getting different error on mulitple ways of getting properties.
It seems like the 'GetPropertyAsDateTime' and 'GetPropertyAsString' and possibly others are causing erros because umbraco.NodeFactory doesn't contain those definitions.
Did something change with the uQuery stuff? Now I am getting
Error occured
d:\WebSites\dmns.org\macroScripts\634865824691844624_DWTListOfPosts.cshtml(298): error CS1061: 'umbraco.NodeFactory.Node' does not contain a definition for 'GetPropertyAsDateTime' and no extension method 'GetPropertyAsDateTime' accepting a first argument of type 'umbraco.NodeFactory.Node' could be found (are you missing a using directive or an assembly reference?)
And in another Controls
Error occured
d:\WebSites\dmns.org\macroScripts\634865827448737268_CrossPromotionUQuery.cshtml(18): error CS1061: 'umbraco.NodeFactory.Node' does not contain a definition for 'GetPropertyAsString' and no extension method 'GetPropertyAsString' accepting a first argument of type 'umbraco.NodeFactory.Node' could be found (are you missing a using directive or an assembly reference?)
OK, I think we have found the issue. In the new uQuery GetPropertyAsString, GetPropertyAsBool, GetPropertyAsDateTime, etc are NOT in the in the Umbraco.Core but WERE in the uComponents.Core. Does not look like the new Umbraco.Core has these properties, and the Umbraco.Legacy.dll does, HOWEVER, we could not access the definitions.
So our solution to our issue with GetPropertyAsDateTime(postDateProperty) is to used the new way that Umbraco.Core's uQuery says to use it as a Generic Type by stating GetProperty<DateTime>(node, "property name") or ours is now GetPropertyAsDateTime(postDateProperty). GetPropertyAsDateTime(postDateProperty) .
Was this intentional? These definitions caused us a LOT of headache until we broke open the DLL's to see what was going on.
So that is the solution
GetPropertyAsDateTime("property name")
is now
GetProperty<DateTime>(node, "property name")
We hope this helps someone else who is having the same issues we were having using some older uComponents definitions that will not work in 4.9.
Hopefully this gets documented someplace too. Would be awesome.
Thanks
is working on a reply...