Fetching sub-page fields dynamically or better method

Totally new to Kirby. I’ve tried the docs but I’m made more confused and not finding answers. I’m basically building a kiosk for local use - not headless - just local.

I want to be able to add child pages that use a ‘popup’ template. A button on the parent opens a popup window, and I fetch the title and layout from the child popup pages. I can then next and previous through however many child popup pages there are - fetching the title and content (not navigating to the page, but getting the fields to dynamically populate the popup).

Currently I have the pages and the popups, templates and blueprints. In the page ‘blueprint’ is a ‘popup_first’ field (a ‘pages’ field) where you select the first popup you want. In the popup template are 2 further pages fields, ‘pop_prev’ and ‘pop_next’ where you can select next/previous pages from which I want to fetch content.

So - when I click a button, the popup opens, fetches the fields of a child based on the page selected and populates the popup.

I have the js for the popup and a good idea of the mechanics. But I’m not sure how to get the children of the current page? I can’t get children of ‘named page’ - as I want to add popups to many pages. How do I get the name or UID, or URI of the current page?

I see the PAGES field stores the page by it’s UUID. Can I fetch the field data using this UUID?

Or am I doing this all wrong? Is there an easier way to do this? Have any number of popup pages I can show in a popup window that the user can page through? My main problem is the whole thing has to be used by people even more stupid than me. Other people will need to be able to add/edit pages and popups.

I’d love to have a multi-page select, and have it cycle through those selected pages in order, creating popup pages, next previous buttons… but I’ve no idea how I would do that :confused:

Sorry for the long question. Please treat me as a designer who has been asked to do a developers job because I know 3 PHP commands and so my boss thinks I’m an expert! Thank you in advance.

You can pass the data you need as data attrubutes, eg the parent page, then fetch the info via AJAX.

Thanks for the quick response, but it doesn’t help at all.

If I add a field to my page ‘editor’ (in the blueprint)… “type: pages”
and then select a page with it (so now that is saved in my page)… how do I get that field, find what page it refers to, and then get the fields from that page?

As I said, I probably shouldn’t be doing this, but I’ve been tasked with it… I have created the whole thing in HTML/JS - but my ‘team’ don’t know html/js - so I need to rebuild it in a way that gives them a visual builder. Kirby seems ideal - but I’m really struggling to understand it. For example: I followed this tutorial to add a button block… Blocks | Kirby CMS - but I don’t get a button block. I don’t get anything at all. I looked through so many pages about using $pages-> get stuff - but still don’t understand how to simply find out what page I’m currently on (e.g. get all child pages of the current page that are template type ‘popup’)

I do pass the data as attributes in my HTML/JS - but have no clue how to actually get the data in Kirby.

Not sure I understand the question, but in your template, you get the page from the field like described in our docs: Files | Kirby CMS

(almost all fields have documentation how to use them in templates).

If you tell us exactly, what you did, we can probably find where the issue is.


gives you all children of the current page

Thank you again… and for clarifying getting current children. I think I can achieve what I want if I understand one more thing…

You said: Not sure I understand the question, but in your template, you get the page from the field like described in our docs: Files | Kirby CMS

But I’m not using files. I am using pages. In my POPUP blueprint I have:

        label: Next Item
        type: pages
        multiple: false

This gives me a field when I edit the POPUP - where I can see all pages, and select one. It then stores it in the text file like this:


Popnext: - page://ot5ezju9Jfy3ReYV

This is the UUID of the page - I think. But I don’t know how to then get this and use it.

In my template, I need to read the ‘popnext’ field for the current page - then find the page it refers to (how?), and get the fields from that page (like layout, subtitle, and popnext).

I hope this makes sense. I’m sorry, I come from HTML and wordpress - so I’m probably using all the wrong terminology…

Sorry, wrong link: Pages | Kirby CMS

Hi Tex. Thanks for your help. I think I got myself in a mess yesterday, but I have poured coffee on it and have things sorted. I now have it so the user can add sub-pages, switch them to template popups, and it automatically fetches them into pages if present and creates all the needed popups and navigation. It’s very elegant and I’m a bit surprised I managed it! :wink:

I am left with one thing which is the buttons. I need ‘not technical’ users to be able to add a button to the layout, which needs to be wysiwyg. I hoped to add ‘button’ to the blocks list in the layout.

Is this possible. Can you point me at the right tutorial, as I followed the tutorial I linked above - but I think for this I have to add the field to my blueprint - so there’s ALWAYS a button… is it possible to instead add it to the layout blocks? Or at least have a ‘add button’ option?

Thanks again

Ok… I figured it out. All my questions answered for now.