# Query value from another blueprint

**URL:** <https://forum.getkirby.com/t/query-value-from-another-blueprint/19636>\
**Category:** Questions\
**Tags:** v3\
**Created:** [October 4, 2020, 9:54am UTC](https://forum.getkirby.com/t/query-value-from-another-blueprint/19636 "2020-10-04T09:54:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lorenzo\_Mason](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lorenzo_mason/32/8632_2.png) [@Lorenzo\_Mason](https://forum.getkirby.com/u/Lorenzo_Mason)\
**Post date:** [October 4, 2020, 9:54am UTC](https://forum.getkirby.com/t/query-value-from-another-blueprint/19636/1 "2020-10-04T09:54:58Z")

</div>

Hi, I’m writing a cart plugin for Kirby.  
I created a page with some toggles to set some plugin settings, for example a toggle to set if there is stock count or not.  
On the product page I’d like to display a field regarding the stock availability if the stock option is true. As the “when” is available only in the same page, how can I check if the toggle on the main page is set to true? Thanks!

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [October 4, 2020, 9:59am UTC](https://forum.getkirby.com/t/query-value-from-another-blueprint/19636/2 "2020-10-04T09:59:19Z")

</div>

The only way that I know of is via a little trick, a hidden field in the same page with the same default value as the toggle field that is updated via a hook when the value of the toggle field in the parent page is changed. Then you can use `when` depending on the value of the hidden field.

---

<div class="post-metadata">

**Author:** ![Lorenzo\_Mason](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lorenzo_mason/32/8632_2.png) [@Lorenzo\_Mason](https://forum.getkirby.com/u/Lorenzo_Mason)\
**Post date:** [October 4, 2020, 10:03am UTC](https://forum.getkirby.com/t/query-value-from-another-blueprint/19636/3 "2020-10-04T10:03:45Z")

</div>

Sounds great! Do you have an example of how the hidden field query the other value? I tried this but is not working…  
if\_stock:  
type: hidden  
querty: “{{site.find(‘cart’).stock}}”

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [October 4, 2020, 10:05am UTC](https://forum.getkirby.com/t/query-value-from-another-blueprint/19636/4 "2020-10-04T10:05:29Z")

</div>

No, you can’t use a query but have to use a hook to fill the value of this field. Maybe it’s possible to use a query for the default value, but I’m not sure if query language can be used with defaults or not. And defaults only work at page creation, anyway. So you can try if this works for the default, but you will still need a hook to update the field when the value in the parent page is changed.

```auto
if_stock:
  type: hidden
  default: “{{site.find('cart').stock}}”

```

If this doesn’t work, then you need two hooks: one at page creation and the second when the parent is updated.

---

<div class="post-metadata">

**Author:** ![Lorenzo\_Mason](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lorenzo_mason/32/8632_2.png) [@Lorenzo\_Mason](https://forum.getkirby.com/u/Lorenzo_Mason)\
**Post date:** [October 4, 2020, 10:10am UTC](https://forum.getkirby.com/t/query-value-from-another-blueprint/19636/5 "2020-10-04T10:10:14Z")

</div>

Right! I think I need the hooks so. It’s something I never did yet 🙂

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [October 4, 2020, 10:10am UTC](https://forum.getkirby.com/t/query-value-from-another-blueprint/19636/6 "2020-10-04T10:10:53Z")

</div>

> [@Lorenzo\_Mason](#):
>
> It’s something I never did yet

Yay, a chance to learn something new!

---

<div class="post-metadata">

**Author:** ![Lorenzo\_Mason](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lorenzo_mason/32/8632_2.png) [@Lorenzo\_Mason](https://forum.getkirby.com/u/Lorenzo_Mason)\
**Post date:** [October 4, 2020, 10:12am UTC](https://forum.getkirby.com/t/query-value-from-another-blueprint/19636/7 "2020-10-04T10:12:26Z")

</div>

🥳
