bnomei / kirby3-qrcode

Generate QRCodes easily.
https://forum.getkirby.com/t/plugin-qr-code-field-and-page-method/6798
MIT License
12 stars 3 forks source link

Template (e.g.) {{ page.panelUrl }} isn't resolved properly in site field #8

Closed teichsta closed 3 years ago

teichsta commented 3 years ago

Thanks a lot for this great enhancement … unfortunately the url template (e.g.) "{{ page.panelUrl }}" isn't resolved properly for me. The option doesn't get resolved but is written into the URL of the QRCode as is. Can you point me to the place where the resolving magic habens (i am still trying to embed the code on the site-document).

teichsta commented 3 years ago

i think i got it. I propose to change index.php as follows:

[L26 if ($url)]

                    if ($url) {
                        if (strpos($url, "|") !== false) {
                            list($url, $slug) = explode("|", $url);
                        }

                        // url seems to be one of the special urls
                        if (Str::startsWith($url, "#")) {
                            $ingredientKey = Str::replace($url, '#', '');
                            $url = kirby()->urls()->$ingredientKey;
                        }

                        $url = \Bnomei\QRCode::query($url, $this->model());

                        if ($page = page($url)) {
                            $url = $page->url();
                            if (empty($slug)) {
                                $slug = $page->slug();
                            }
                        }

                        if (empty($slug)) {
                            $slug = $url;
                        }

                        // create safe slug ...
                        $slug = \Kirby\Toolkit\Str::slug($slug);
                    } else {

i introduced a new special query beginning with "#" wich queries the special kirby->urls(). Valid values can be index, base, current, assets, api, media, panel.

What do you think?