Is possible to get pages which were created by user in umbraco cms. For example my username is admin, and I want to get list all of pages which were created by me using c# code (page name and page url).
It is possible and pretty straight forward. Here are a couple of examples (I'm using razor to spit out the values, but this could easily be put into a user control, or written out to a file or whatever):
Using DynamicNode :
@{
var userId = 0; //admin
var root = Library.NodeById(-1);
var nodes = root.Descendants().Where("CreatorId == @0", userId);
foreach (var node in nodes)
{
@:@node.Id, @node.Name, @node.Url<br />
}
}
Using NodeFactory and uQuery :
@{
var userId = 0; //admin
var root = new Node(-1);
var nodes = root.GetDescendantNodes(n => n.CreatorID == userId);
foreach (var node in nodes)
{
@:@node.Id, @node.Name, @node.Url<br />
}
}
Just replace 0
withe the Id of your user.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.