I have a panel field with a dropdown containing all the pages of the site. But when I want to call to this value in the template Im getting the name of the page not the page object. How can I get the url of the page?
Previously I’ve used
$pages->find() but in this case I have to find in all the pages of the site. How can I achieve this?
What is saved in the content file? The complete path or only the uid?
What kind of value does your field store? The UID (folder name) of the page or the full URI?
blog/my-blog-post (URI) vs
You have to store the URI to be able to convert it to a page object. It works like this then:
$p = page((string)$page->mypagefield());
If you have saved the URI, you can also use the
value() method to get a string:
$p = page($page->mypagefield()->value());
The UID is stored In the content file.
In the panel Im trying to get the page with this blueprint.
You can change your field definition like this to save the URI:
Thank you!! I will give a try.
Hi there. Im using 2.3.2 as trial. I have read the docs regarding the field type “page” and “query” and I am trying to link some pages at the homepage show a shorttext and a link.
I have tried “type: page” before and had the same results displayed below.
label: Related Page 1
$p = page((string)$page->pagerel());
Result in the page:
I’m really desperate since I want to enable my client a comfortable solution to link to the pages in a structured (and fail save) manner.
What am I doing wrong here? (Used the Starter template for testing and enabled Multilanguage)
Have you tested the output of the German language version? If the related page should be the same for all languages, you should use the
translate: false option.
The rest of the blueprint and template look fine however.
Disabled Multilanguage, deleted unneccesary files, and it works. I had home.de.txt home.nl.txt and home.txt in my directory
Then it was the
home.txt. In a multilang installation you can only have content files with language codes.
I had renamed the page. But I tried a multidomain/multi-content-folder page. It must somehow have reappeared when I saved via the panel.
But I’m evaluating if to use kirby or wordpress multisite.
As long as the markdown-editing will be accepted by the customer, I’ll use kirby. \o/