Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dan Smith 5 posts 76 karma points
    Aug 10, 2015 @ 01:09
    Dan Smith
    0

    Query Builder never returns any results

    Hi!

    I'm new to Umbraco and so I'm probably making a basic mistake, but here goes:

    I have created a simple Document Type, "Hours of Operation", and added 7 textstring properties for each day of the week. I just want to use this to store the hours the shop is open. I enabled "Allow at root" and saved it. Then I went to Content and created an instance of "Hours of Operation" and filled out the 7 fields.

    Then I created a new template and called it "Master" with the intentions of making it the master page for all others. While editing the master page, and I try to use the Query Builder, no combination of I want "everything" from "my website" returns any results.

    I have verified that the hours of operation are published but nothing I do returns results. Do I need to create a data type or something?

    Thanks!

    T

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Aug 10, 2015 @ 07:07
    Sebastiaan Janssen
    0

    I'm not entirely sure what you're expecting to get back but when you first start the query builder, it should look a little like this:

    enter image description here

    Here you see I have one result, the Blog is the root of my website. If you have any published(!) content in the root of your site you should see something similar for your Hours of Operation root node. Is that what you're not seeing?

  • Dan Smith 5 posts 76 karma points
    Aug 10, 2015 @ 13:51
    Dan Smith
    0

    Yes, I am expecting to see something similar to your example. However, when I try I get nothing:

    enter image description here

    The only thing I can think is that I do not have a template assigned to this document type because I only want the document type to store 7 strings that I can query later and use in a master page.

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Aug 10, 2015 @ 14:30
    Sebastiaan Janssen
    0

    Hmmm, weird, what does your content tree look like, got a screenshot of that?

  • Dan Smith 5 posts 76 karma points
    Aug 10, 2015 @ 20:29
    Dan Smith
    0

    enter image description here

    Thanks for looking!

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Aug 10, 2015 @ 20:49
    Sebastiaan Janssen
    0

    Well, that looks absolutely fine, sorry you're not having much luck here! Do you have any javascript errors?

    One other thought: what template is that content item using? Is there any template attached here?

    Other than that you should be able to do something like this:

    @{
        Layout = null;
        // Go to the first node that's found on level 1
        var rootNode = Model.Content.AncestorOrSelf(1);
    }
    <span>Monday: @(rootNode.GetPropertyValue<string>("openingHour1"));</span>
    

    This all depends on the property alias of course (I chose "openingHour1" in this example) but this should work.

    To be sure: you need to tell your Hours Of Operation document type that it can use the Master template and if you had not done that yet, you will need to publish the Hours of Operation node again, after selecting the template on the Properties tab.

  • Dan Smith 5 posts 76 karma points
    Aug 10, 2015 @ 22:45
    Dan Smith
    0

    I think I am asking the wrong question.

    What I need, is to display the same information on many pages in different ways.

    I would like the source data to be in one location, so that when I change the hours for Monday it changes on Page X, Page Y, etc.

    I THINK I need a document so that I can create a content node that will store this information. I had hoped that if I did this, I would be able to simple use the query builder to access that information, but maybe I am mistaken.

    How would you go about storing what is essentially 1 row of data in table and then access it anywhere?

    Thanks!

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Aug 10, 2015 @ 22:47
    Sebastiaan Janssen
    0

    I would go about it the exact way I illustrated above. :-) Does that work for you?

  • Dan Smith 5 posts 76 karma points
    Aug 11, 2015 @ 00:24
    Dan Smith
    1

    Thank you for all of your help -I really appreciate it.

    I got it to work finally.

    I made a "Home" document type to serve as the root for my site. As a subtype, I made the "Hours of Operation" document type.

    Then I created a "Home" content node, and an "Hours" content node. Then when I went back to edit the Home template, the query builder worked as expected.

    I have no idea why it worked this way. I surmise I am not allowed to have 2 root content nodes, but it is just a guess.

    Anyways, thanks again..

    -T

  • Ali Z 31 posts 173 karma points
    Jul 23, 2019 @ 07:22
    Ali Z
    0

    Spent too much time on this... Thank you your feedback helped

Please Sign in or register to post replies

Write your reply to:

Draft