using Umbraco.Web.UI.Controls;
namespace TESTING.Umbraco
{
public class UmbracoHelper
{
void Parse(UmbracoHelper node);
}
}
Than, in another .cs file, I have the following:
var umbracoHelper = new Umbraco.Web.UmbracoHelper(Umbraco.UmbracoContext.Current);
But Visual Studio is giving me flag on .Web, saying that the namespace Web does not exist in the namespace TESTING.Umbraco
Basically, I would like to call a method inside my class files, called Parse() that would take UmbracoHelper into it, which will work, but I don't seem to have many properties for Umbraco Helper... example:
private static Menu Parse (UmbracoHelper aNode)
{
aNode.??? (Not much to get here...)
}
How can I do this exactly? Seems I am not doing this right. I just want to get all properties from a node so that it can be outputted... UmbracoHelper is what I thought I needed, but doesn't seem like it is right, or I'm not using it right...
From your last code example, you have named your parameter 'aNode'. An instance of the UmbracoHelper class is not a representation of a published page. It is a class to help with published content. For example, if you wanted to get a node, you would have to use the following method:
var aNode = new UmbracoHelper(UmbracoContext.Current).TypedContent(123);
Also, you have named your class UmbracoHelper. Are you trying to create an extension method or a class? If its the later, I would recommend naming it something else to not confuse things with Umbraco's UmbracoHelper class. Maybe something like the following:
public static class UmbracoHelperExtensions
{
public static Menu Parse(this UmbracoHelper helper)
{
var rootId = 1234;
var rootNode = helper.TypedContent(rootId);
...
}
}
You would then be able to use the extension method as follows:
var helper = new UmbracoHelper(UmbracoContext.Current);
var menu = helper.Parse();
Just to add to this, it seems you are using the namespace Umbraco elsewhere as well. Make sure to avoid using Umbraco in your namespaces and classnames so that you don't clash with our namespaces and clssass names.
Hello, thanks for your feedback. I am not able to access UmbracoContext, only HttpContext is accessible. Why can I not access UmbracoContext? This is also the case for ApplicationContext. Both of these are inaccessible and cause errors. Only able to access HttpContext. Any suggestions on how to debug/fix this?
How to get UmbracoHelper working here?
In a .cs file, I have the following:
Than, in another .cs file, I have the following:
But Visual Studio is giving me flag on
.Web
, saying that the namespaceWeb
does not exist in the namespaceTESTING.Umbraco
Basically, I would like to call a method inside my class files, called
Parse()
that would take UmbracoHelper into it, which will work, but I don't seem to have many properties for Umbraco Helper... example:How can I do this exactly? Seems I am not doing this right. I just want to get all properties from a node so that it can be outputted... UmbracoHelper is what I thought I needed, but doesn't seem like it is right, or I'm not using it right...
Can anyone help me please?
Hi Soloman,
From your last code example, you have named your parameter 'aNode'. An instance of the UmbracoHelper class is not a representation of a published page. It is a class to help with published content. For example, if you wanted to get a node, you would have to use the following method:
Also, you have named your class UmbracoHelper. Are you trying to create an extension method or a class? If its the later, I would recommend naming it something else to not confuse things with Umbraco's UmbracoHelper class. Maybe something like the following:
You would then be able to use the extension method as follows:
Thanks, Dan.
Just to add to this, it seems you are using the namespace Umbraco elsewhere as well. Make sure to avoid using Umbraco in your namespaces and classnames so that you don't clash with our namespaces and clssass names.
Hello, thanks for your feedback. I am not able to access UmbracoContext, only HttpContext is accessible. Why can I not access UmbracoContext? This is also the case for ApplicationContext. Both of these are inaccessible and cause errors. Only able to access HttpContext. Any suggestions on how to debug/fix this?
is working on a reply...