Hi @ryankienstra , I was able to figure it out after a few google search. I had an issue with the naming convention of the blocks. I didn’t know that I had to prepend my php file with ‘block-‘.
I have a question about rendering values on the front-end from a loop. See my code below:
<?php
$json = '{"surveys":[{"name":"Dev Survey","description":"Dev Survey","links":[{"name":"Test Survey","url":"https://www.yahoo.com/?"}]},{"name":"Dev Survey 2","description":"Dev Survey 2","links":[{"name":"Dev Survey 2","url":"https://www.google.com/"}]}]}';
$surveys = json_decode($json, true);
foreach ($surveys['surveys'] as $key => $value) {
foreach ($value['links'] as $key1 => $value1) {
$fields = array(
'survey-links' => array(
'label' => $value1['name'],
'control' => 'text',
'default' => $value1['url'],
),
'survey-button' => array(
'label' => 'Button',
'control' => 'text',
'default' => $value1['name'],
)
);
}
}
?>
With the code above, only the last item in survey-links array renders on the page, but what if I wanted to render all urls? is there a way to loop from block_field(‘survey-links’); function? Ideally I want to display the urls in separate div on the page/post. I hope my my inquiry make sense. Thank you in advance!
-
This reply was modified 4 years, 4 months ago by
teemberland.