Closed isaactopo closed 6 years ago
This would only work if every page on your website had a contact-info
child page. Have you tried page('contact-info')->email()
?
Thanks for your reply, the code is something like this:
c::set('meta-tags.templates', function(Page $page, Site $site) {
return [
'gym' => [
'json-ld' => [
'ExerciseGym' => [
'name' => 'whatever '. $page->title()->value(),
'image' => $page->image($page->briefImage())
? $page->image($page->briefImage())->url()
: site()->images()->sortBy('sort', 'asc')->first()->url(),
'url' => $site->url(),
'telephone' => $page->children()->find('contact-info')->tel(),
]
]
]
];
});
As you say I tried to access with method page('some-page')
but does not work as well.
It seems imposible to work with children
and page
methods.
$page->title()->value()
is working fine.
Please try: page('contact-info')->tel()->value()
ok, the value() does the trick. Thanks for your help.
Under the hood the plugin used json_encode
to generate the JSON-LD markup. Kirby fields are Field
objects and need to be converted to string
before, that's what the value()
method does, it converts the object
to string
.
Hi Pedro, there's a way to get this working?:
$page->children()->find('contact-info')->email()
I can't access to this field using
children()->find()
. Thanks for the great plugin!