I am trying to find all nodes which contains the property "documentChooser", with the umbracohelper.
But I cannot find any equivalent to "currentpage.site". How is that done.?
'UmbracoHelper' does not contain a definition for 'Site' and no extension method 'Site'
public ContentResult PostMeNow()
{
var umbracoHelper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
var _site = umbracoHelper.Site()... <-- Error message
'UmbracoHelper' does not contain a definition for 'Site' and no extension method 'Site'
foreach(var child in _site {
if (child.documentChooser.Url)
{
///
}
}
return ....
}
Do you have one site in you Umbraco installation or do you have more than one?
If you only have one I'm guessing......you what you want to do is get a list of all nodes that have a particular property?
This will give you the root node.
var umbracoContext = Umbraco.Web.UmbracoContext.Current;
var umbracoHelper = new Umbraco.Web.UmbracoHelper(umbracoContext);
rootnode = umbracoHelper.TypedContentAtRoot();
Then you can look for all nodes that are of a given document type (the document type that has the property your looking for)
like this:
var nodesyouwant = rootnode.Where(x => x.DocumentTypeAlias == "yourDocTypeAliasHere");
Thanks guys!
I got what I needed, a list of media-urls from the media picker on the node.
I trying to test the url up against the IHttpHandler Context, so I can prevent someone to download a PDF which is extranet protected, under a specific extranet page. Not all pdfs on the solution, should be protected, so I needed some way to find the urls for the protected PDFs only.
This was the last code I needed :-)
var umbracoHelper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
string _childrenName = "";
string _childrenID = "";
List<IPublishedContent> listOfNodeWithProperty = new List<IPublishedContent>();
IEnumerable<IPublishedContent> rootNodes = umbracoHelper.TypedContentAtRoot();
foreach (IPublishedContent rootNode in rootNodes)
{
listOfNodeWithProperty.AddRange(rootNode.Descendants().Where(x => x.HasProperty("documentChooser")));
}
foreach (var child in listOfNodeWithProperty)
{
_childrenID = child.GetPropertyValue("documentChooser").ToString();
var media = umbracoHelper.TypedMedia(_childrenID);
_childrenName += "/ " + media.Url();
}
return Content(_childrenName);
UmbracoHelper - find all pages with attribute
Hi There.
I am trying to find all nodes which contains the property "documentChooser", with the umbracohelper. But I cannot find any equivalent to "currentpage.site". How is that done.?
'UmbracoHelper' does not contain a definition for 'Site' and no extension method 'Site'
Do you have one site in you Umbraco installation or do you have more than one?
If you only have one I'm guessing......you what you want to do is get a list of all nodes that have a particular property?
This will give you the root node.
Then you can look for all nodes that are of a given document type (the document type that has the property your looking for)
like this:
hope that helps. Ayo
Hi.
I think i know what you trying to do.
Thanks guys! I got what I needed, a list of media-urls from the media picker on the node. I trying to test the url up against the IHttpHandler Context, so I can prevent someone to download a PDF which is extranet protected, under a specific extranet page. Not all pdfs on the solution, should be protected, so I needed some way to find the urls for the protected PDFs only. This was the last code I needed :-)
is working on a reply...