Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8612359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:36:25+00:00 2026-06-12T04:36:25+00:00

Just trying to get some perspective about how to retrieve data from umbraco via

  • 0

Just trying to get some perspective about how to retrieve data from umbraco via the API method. I believe we are using umbraco 4.9.x.

Basically there is a data type called DiaryEventItems, and I use the following code to access this:

// Get the ID of the data type
DocumentType DocTypeDiaryEvents = DocumentType.GetByAlias("DiaryEventItems");

// Loop through those items using a foreach at present
foreach (Document DiaryEvent in Document.GetDocumentsOfDocumentType(DocTypeDiaryEvents.Id))
{
    // Do whatever I need to
}

So this works well.. I get back the collection/rows of “DiaryEventItems”, however I get ALL DiaryEventItems from the umbraco instance of course.. i.e. for all sites. So obviously there are methods to get the site root node ID and perhaps work down the tree to get the actual document type I need, however is there some way of doing this which is similar to the above code?

Any help appreciated thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:36:27+00:00Added an answer on June 12, 2026 at 4:36 am

    you can try following function for only Published node:

    // this is variable to retrieve Node list
    private static List<Node> listNode = new List<Node>();
    
    public static List<Node> GetDescendantOrSelfNodeList(Node node, string nodeTypeAlias)
    {
        if (node.NodeTypeAlias == nodeTypeAlias)
            listNode.Add(node);
    
        foreach (Node childNode in node.Children)
        {
            GetDescendantOrSelfNodeList(childNode, nodeTypeAlias);
        }
    
        return listNode;
    }
    

    now you can call that function in your code as below:

    // 1234 would be root node id
    Node rootNode = new Node(1234)
    
    // we are passing root node so that it can search through nodes with alias as DiaryEventItems
    List<Node> diaryEventItems = GetDescendantOrSelfNodeList(rootNode, "DiaryEventItems");
    

    I hope this would help,
    if you looking for unpublished node with Document and its different and will be taking little bit time for me but if you want unpublished node only then i’ll do that bit later.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get some data from remote server. To achieve this I
Basically i'm trying to get some IPTC data from an image when a user
I'm trying to get some data from a PHP file which only gives a
I am new to the communication side. Was just trying to get some data
I've been using jQuery for some days now, just trying to get use to
I am trying to get some data from Magento trough php, it works but
Just trying to get some rows out of a database and loop through but
Im trying to get this working but for some reason it's just not right.
So I just recently bought some web hosting and I'm trying to get my
I'm just trying to get into the benefits of using CSS vs. tables, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.