# Plugin starter questions

**URL:** <https://forum.getkirby.com/t/plugin-starter-questions/18857>\
**Category:** Questions\
**Tags:** v3\
**Created:** [July 23, 2020, 7:59am UTC](https://forum.getkirby.com/t/plugin-starter-questions/18857 "2020-07-23T07:59:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gegerino](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gegerino/32/8805_2.png) [@gegerino](https://forum.getkirby.com/u/gegerino)\
**Post date:** [July 23, 2020, 7:59am UTC](https://forum.getkirby.com/t/plugin-starter-questions/18857/1 "2020-07-23T07:59:06Z")

</div>

Hi everybody,

I try to create a plugin with a dynamic blueprint and now I have two questions.

1. how can i debug my plugin-blueprint? if i call a var\_dump the page breaks with an error.
2. how can i get the current page in the blueprint? if i use page() it is aways the root, but I need the current page.

thanks in advance

---

<div class="post-metadata">

**Author:** ![bnomei](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bnomei/32/775_2.png) [@bnomei](https://forum.getkirby.com/u/bnomei)\
**Post date:** [July 23, 2020, 8:57am UTC](https://forum.getkirby.com/t/plugin-starter-questions/18857/2 "2020-07-23T08:57:13Z")

</div>

hi @gegerino. welcome to the forum.

- what exactly do you mean with “dynamic blueprint”? a blueprint file and template file registered via plugin?
- can you share some of your code for questions 1 and 2?

---

<div class="post-metadata">

**Author:** ![gegerino](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gegerino/32/8805_2.png) [@gegerino](https://forum.getkirby.com/u/gegerino)\
**Post date:** [July 23, 2020, 9:03am UTC](https://forum.getkirby.com/t/plugin-starter-questions/18857/3 "2020-07-23T09:03:04Z")

</div>

Here is my code:  
\<?php  
Kirby::plugin(‘digtive/productanswers’, [  
‘blueprints’ =\> [  
‘pages/product’ =\> require\_once **DIR**. ‘/blueprints/pages/product.php’  
],  
]);

product.php -\> blueprint-file:  
\<?php  
$blueprint = [  
‘title’ =\> ‘Product’,  
‘status’ =\> [  
‘draft’ =\> ‘Draft’,  
‘listed’ =\> ‘Published’  
],  
‘options’ =\> [  
‘preview’ =\> false,  
],  
‘columns’ =\> [  
‘main’ =\> [  
‘width’ =\> ‘1/2’,  
‘sections’ =\> [  
‘content’ =\> [  
‘type’ =\> ‘fields’,  
‘fields’ =\> [  
‘headline’ =\> [  
‘label’ =\> ‘Überschrift’,  
‘type’ =\> ‘text’  
]  
]  
]  
]  
],  
‘left\_side’ =\> [  
‘width’ =\> ‘1/2’,  
‘sections’ =\> [  
‘side’ =\> [  
‘type’ =\> ‘fields’,  
‘fields’ =\> []  
]  
]  
]  
]  
];

```
$questions = page('gnss')->find('questions')->children()->published();
//this crashes var_dump($questions);
foreach($questions as $question):
    $questions_array[$question->title()->value()] = [
        'label' => $question->title()->value(),
        'type' => 'multiselect'
    ];
endforeach;

$blueprint['columns']['left_side']['sections']['side']['fields'] = $questions_array;

return $blueprint;
```

---

<div class="post-metadata">

**Author:** ![gegerino](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gegerino/32/8805_2.png) [@gegerino](https://forum.getkirby.com/u/gegerino)\
**Post date:** [July 23, 2020, 9:06am UTC](https://forum.getkirby.com/t/plugin-starter-questions/18857/4 "2020-07-23T09:06:15Z")

</div>

sorry for this ugly formation

---

<div class="post-metadata">

**Author:** ![bnomei](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bnomei/32/775_2.png) [@bnomei](https://forum.getkirby.com/u/bnomei)\
**Post date:** [July 23, 2020, 9:07am UTC](https://forum.getkirby.com/t/plugin-starter-questions/18857/5 "2020-07-23T09:07:19Z")

</div>

> [@gegerino](#):
>
> `$questions = page('gnss')-> ....`

the `page` helper will not work since all your code is loaded as part of the config and kirby is not ready yet. you could try and defer some of your plugins logic to the [ready option](https://getkirby.com/docs/reference/system/options/ready). but i am not sure this will work with the blueprint you have in mind.

---

<div class="post-metadata">

**Author:** ![bnomei](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bnomei/32/775_2.png) [@bnomei](https://forum.getkirby.com/u/bnomei)\
**Post date:** [July 23, 2020, 9:10am UTC](https://forum.getkirby.com/t/plugin-starter-questions/18857/6 "2020-07-23T09:10:46Z")

</div>

but instead of `page` you could walk the dir tree and create virtual page objects based on your content file using `Page::factory`.

> **[Simple virtual page](https://getkirby.com/docs/guide/virtual-pages/simple-virtual-page)**
>
> Add an ad-hoc virtual page quickly via a simple route

---

<div class="post-metadata">

**Author:** ![gegerino](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gegerino/32/8805_2.png) [@gegerino](https://forum.getkirby.com/u/gegerino)\
**Post date:** [July 23, 2020, 9:12am UTC](https://forum.getkirby.com/t/plugin-starter-questions/18857/7 "2020-07-23T09:12:28Z")

</div>

okay… thx  
and is it possible to do a var\_dump or something in my blueprint?

---

<div class="post-metadata">

**Author:** ![bnomei](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bnomei/32/775_2.png) [@bnomei](https://forum.getkirby.com/u/bnomei)\
**Post date:** [July 23, 2020, 9:14am UTC](https://forum.getkirby.com/t/plugin-starter-questions/18857/8 "2020-07-23T09:14:05Z")

</div>

since its part of kirbys init i do not think so. but you could dump it to a file.

```auto
$msg = print_r($var, true); // if you need a var not just a string
@file_put_contents($file, $msg, FILE_APPEND);

```

---

<div class="post-metadata">

**Author:** ![gegerino](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gegerino/32/8805_2.png) [@gegerino](https://forum.getkirby.com/u/gegerino)\
**Post date:** [July 23, 2020, 9:19am UTC](https://forum.getkirby.com/t/plugin-starter-questions/18857/9 "2020-07-23T09:19:44Z")

</div>

Cool… that’s awesome 👍
