I am fetching an entry with drop-down values and When I print the entry the values are in the entry object. When I try to print the value like entry.dropdown.value it causes additional DB queries to display the data.

As I have a menu structure with a lot of links works were displayed based on the drop-down value. It causes the number of queries to double. Please correct me if am wrong. Am I making the call correctly? or this is how Craft CMS will work? or is there any workaround?

  • 1
    Accessing the field sholdn't cause additional DB queries if the entry was fully loaded and populated. Please post your template so we can see what's going on.
    – MoritzLost
    May 17 at 7:37
  • @MoritzLost Used like the below, {% set entry = craft.entries().id(xxx).one() %} {{ entry.menuType }} Here menuType is dropdown feild. and tried {{ entry.menuType.value }} also.
    – Parthiban
    May 17 at 10:02
  • 1
    Hm, I don't think this should cause an additional DB query. How are you determining that it does? Maybe it's just an observer effect, or you're looking at the wrong part of the template.
    – MoritzLost
    May 17 at 15:08
  • @MoritzLost I am determining this when I check the DB queries via debug console in the frontend. if I add those print statements I could see the number of quires spikes.
    – Parthiban
    May 18 at 7:30


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.