I’ve got two social media structures set up on my website. One where users can set the different social media they want to be able to select sitewide:
setsocial:
label: Set Social Platforms
type: structure
fields:
platformname:
label: Platform Name
type: text
fillicon:
label: Platform Icon Fill
type: files
help: Make sure the icons have a transparent background!
max: 1
query: site.files
buttonicon:
label: Platform Icon Button
type: files
max: 1
query: site.files
inverticon:
label: Platform Icon Inverted
type: files
max: 1
query: site.files
and another where they can then set the specific URLs and platforms for different instances across the site:
label: Social
type: structure
fields:
platform:
label: Platform
type: select
width: 1/2
options: query
query:
fetch: site.setsocial.toStructure
text: "{{ structureItem.platformName }}"
value: "{{ structureItem }}"
url:
label: URL
type: text
width: 1/2
I’ve been trying to figure out how in my snippet to pull through contents from one structure to another. Using structureItem
as a value this YAML
seems to pass through an array because things like this get me array to string conversion errors:
<?php foreach($links as $sitem):
$splatform = $sitem->platform();
$spurl = $sitem->url();
?>
<?= $splatform->yaml() ?>
<?php endforeach ?>
but then when I try to access the content like an array such as
<?= $splatform[0] ?>
I then get an error that it can’t be treated like an array. Is there a better way to access the setSocial
structure content? (specifically the images) and does something like {{ structureItem }}
actually even work?