# How to use a page-method in the blueprint?

**URL:** <https://forum.getkirby.com/t/how-to-use-a-page-method-in-the-blueprint/23682>\
**Category:** Questions\
**Tags:** v3\
**Created:** [October 15, 2021, 1:43pm UTC](https://forum.getkirby.com/t/how-to-use-a-page-method-in-the-blueprint/23682 "2021-10-15T13:43:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pesto](https://avatars.discourse-cdn.com/v4/letter/p/f04885/32.png) [@pesto](https://forum.getkirby.com/u/pesto)\
**Post date:** [October 15, 2021, 1:43pm UTC](https://forum.getkirby.com/t/how-to-use-a-page-method-in-the-blueprint/23682/1 "2021-10-15T13:43:38Z")

</div>

Hi,

im am trying to set the image-ratio of a files-field in the blueprint by custom page-method.  
The idea is to get the settings for the current page, or falling back to parent- or site-settings if not set on the page.

It´s basically working by getting a page-object via the file-object:

```auto
files:
  type: files
  layout: cards
  image:
    ratio: "{{file.parent.getCoverRatio()}}"

```

Unfortunately this returns the page-object of the page where the file is stored, and not the page where the image is used.

The following syntax is not working for me (kirby 3.6.0.beta.3):

```auto
files: 
  ...
  image:
    ratio: "{{page.getCoverRatio()}}"

```

How can I use the page-method directly in the blueprint?

Cheers  
Peter

---

<div class="post-metadata">

**Author:** ![moonwalk](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@moonwalk](https://forum.getkirby.com/u/moonwalk)\
**Post date:** [October 15, 2021, 1:59pm UTC](https://forum.getkirby.com/t/how-to-use-a-page-method-in-the-blueprint/23682/2 "2021-10-15T13:59:23Z")

</div>

> [@pesto](#):
>
> Unfortunately this returns the page-object of the page where the file is stored, and not the page where the image is used.

According to your field settings (since you are not using a query), I would assume that the file is stored where it is used?

---

<div class="post-metadata">

**Author:** ![pesto](https://avatars.discourse-cdn.com/v4/letter/p/f04885/32.png) [@pesto](https://forum.getkirby.com/u/pesto)\
**Post date:** [October 15, 2021, 2:03pm UTC](https://forum.getkirby.com/t/how-to-use-a-page-method-in-the-blueprint/23682/3 "2021-10-15T14:03:44Z")

</div>

Sorry moonwalk, the query was left out:

```auto
files:
  type: files
  layout: cards
  image:
    ratio: "{{file.parent.getCoverRatio()}}"
  query: site.find('photography').children.images
  ...

```

Site methods do work too:

```auto
files:
  ...
  image:
    ratio: "{{site.getCoverRatio()}}"
  ...

```

Why not

```auto
ratio: "{{page.getCoverRatio()}}"

```

---

<div class="post-metadata">

**Author:** ![moonwalk](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@moonwalk](https://forum.getkirby.com/u/moonwalk)\
**Post date:** [October 15, 2021, 2:49pm UTC](https://forum.getkirby.com/t/how-to-use-a-page-method-in-the-blueprint/23682/4 "2021-10-15T14:49:10Z")

</div>

The blueprint doesn’t know what page is in this context. You can only get information in relation to the file, i.e. file.parent or via a file method.

---

<div class="post-metadata">

**Author:** ![pesto](https://avatars.discourse-cdn.com/v4/letter/p/f04885/32.png) [@pesto](https://forum.getkirby.com/u/pesto)\
**Post date:** [October 15, 2021, 2:55pm UTC](https://forum.getkirby.com/t/how-to-use-a-page-method-in-the-blueprint/23682/5 "2021-10-15T14:55:00Z")

</div>

Why is that?

We can use the page object in other fields like:

```auto
published:
  headline: Published Pages
  type: pages
  info: "Year: {{ page.year }}"

```

Or:

```auto
tags:
    label: Tags
    type: tags
    options: query
    query:
      fetch: page.siblings
      text: " {{ page.title }}"
      value: "{{ page.uri }}"

```

According to: [Query Language | Kirby CMS](https://getkirby.com/docs/guide/blueprints/query-language)

---

<div class="post-metadata">

**Author:** ![moonwalk](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@moonwalk](https://forum.getkirby.com/u/moonwalk)\
**Post date:** [October 15, 2021, 2:56pm UTC](https://forum.getkirby.com/t/how-to-use-a-page-method-in-the-blueprint/23682/6 "2021-10-15T14:56:47Z")

</div>

Yes, but there you are in the relevant page contexts, whereas in a files field/section, you are in the context of the file.

---

<div class="post-metadata">

**Author:** ![pesto](https://avatars.discourse-cdn.com/v4/letter/p/f04885/32.png) [@pesto](https://forum.getkirby.com/u/pesto)\
**Post date:** [October 15, 2021, 3:02pm UTC](https://forum.getkirby.com/t/how-to-use-a-page-method-in-the-blueprint/23682/7 "2021-10-15T15:02:29Z")

</div>

Ok, but the field/sections is defined in the context of a specific page-blueprint.  
😕  
:scrapping my head:

So, the page-object is not passed down into the files-field?
