We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have the following test JSON data returned from an API { "products": [ { "ID": 271, "post_author": "1", "post_date": "2022-01-07 13:25:07", "post_date_gmt": "2022-01-07 13:25:07", "post_content": "test ", "post_title": "Test Product 2", "post_type": "product", "post_mime_type": "", "comment_count": "0", "filter": "raw", "product_type": "Gift", "product_start_date": "2022-01-14 00:00:00", "product_end_date": "2022-01-22 00:00:00", "product_price": "12.00", "product_condition": "new", "product_location": "Nottingham", "product_images": [ "products/271/ygm_primary_logo.png" ] }, { "ID": 270, "post_author": "1", "post_date": "2022-01-05 22:55:27", "post_date_gmt": "2022-01-05 22:55:27", "post_content": "test", "post_title": "Test Product 1", "product_type": "Gift", "product_start_date": "2022-01-06 00:00:00", "product_end_date": "2022-01-15 00:00:00", "product_price": "22.00", "product_condition": "new", "product_location": "Hucknall", "product_images": [ "products/270/ygm_yellowface_click.png", "products/270/ygm_logo_small.png", "products/270/ygm_reversed_logo.png", "products/270/ygm_flyer_dec_front_sold_out.png" ] } ] }
{ "products": [ { "ID": 271, "post_author": "1", "post_date": "2022-01-07 13:25:07", "post_date_gmt": "2022-01-07 13:25:07", "post_content": "test ", "post_title": "Test Product 2", "post_type": "product", "post_mime_type": "", "comment_count": "0", "filter": "raw", "product_type": "Gift", "product_start_date": "2022-01-14 00:00:00", "product_end_date": "2022-01-22 00:00:00", "product_price": "12.00", "product_condition": "new", "product_location": "Nottingham", "product_images": [ "products/271/ygm_primary_logo.png" ] }, { "ID": 270, "post_author": "1", "post_date": "2022-01-05 22:55:27", "post_date_gmt": "2022-01-05 22:55:27", "post_content": "test", "post_title": "Test Product 1", "product_type": "Gift", "product_start_date": "2022-01-06 00:00:00", "product_end_date": "2022-01-15 00:00:00", "product_price": "22.00", "product_condition": "new", "product_location": "Hucknall", "product_images": [ "products/270/ygm_yellowface_click.png", "products/270/ygm_logo_small.png", "products/270/ygm_reversed_logo.png", "products/270/ygm_flyer_dec_front_sold_out.png" ] } ] }
I then decode it in PHP (output below) and pass it into Jellyfish like so $page->set("products", json_decode($json, true));
$page->set("products", json_decode($json, true));
array (size=1) 'products' => array (size=2) 0 => array (size=31) 'ID' => int 271 'post_author' => string '1' (length=1) 'post_date' => string '2022-01-07 13:25:07' (length=19) 'post_date_gmt' => string '2022-01-07 13:25:07' (length=19) 'post_content' => string 'hijhjkhbkj hj ' (length=14) 'post_title' => string 'Test Product New' (length=16) 'product_type' => string 'Gift' (length=4) 'product_start_date' => string '2022-01-14 00:00:00' (length=19) 'product_end_date' => string '2022-01-22 00:00:00' (length=19) 'product_price' => string '12.00' (length=5) 'product_condition' => string 'new' (length=3) 'product_location' => string 'Nottingham' (length=10) 'product_images' => array (size=1) ...
But in my template file I am not sure how to iterate through and call? any help would be great. The below code just returns 'Array'
{% for key=>item in {{ products }} %} <b>{{key}}->{{item}}</b> {%endfor%}
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I have the following test JSON data returned from an API
{ "products": [ { "ID": 271, "post_author": "1", "post_date": "2022-01-07 13:25:07", "post_date_gmt": "2022-01-07 13:25:07", "post_content": "test ", "post_title": "Test Product 2", "post_type": "product", "post_mime_type": "", "comment_count": "0", "filter": "raw", "product_type": "Gift", "product_start_date": "2022-01-14 00:00:00", "product_end_date": "2022-01-22 00:00:00", "product_price": "12.00", "product_condition": "new", "product_location": "Nottingham", "product_images": [ "products/271/ygm_primary_logo.png" ] }, { "ID": 270, "post_author": "1", "post_date": "2022-01-05 22:55:27", "post_date_gmt": "2022-01-05 22:55:27", "post_content": "test", "post_title": "Test Product 1", "product_type": "Gift", "product_start_date": "2022-01-06 00:00:00", "product_end_date": "2022-01-15 00:00:00", "product_price": "22.00", "product_condition": "new", "product_location": "Hucknall", "product_images": [ "products/270/ygm_yellowface_click.png", "products/270/ygm_logo_small.png", "products/270/ygm_reversed_logo.png", "products/270/ygm_flyer_dec_front_sold_out.png" ] } ] }
I then decode it in PHP (output below) and pass it into Jellyfish like so
$page->set("products", json_decode($json, true));
array (size=1) 'products' => array (size=2) 0 => array (size=31) 'ID' => int 271 'post_author' => string '1' (length=1) 'post_date' => string '2022-01-07 13:25:07' (length=19) 'post_date_gmt' => string '2022-01-07 13:25:07' (length=19) 'post_content' => string 'hijhjkhbkj hj ' (length=14) 'post_title' => string 'Test Product New' (length=16) 'product_type' => string 'Gift' (length=4) 'product_start_date' => string '2022-01-14 00:00:00' (length=19) 'product_end_date' => string '2022-01-22 00:00:00' (length=19) 'product_price' => string '12.00' (length=5) 'product_condition' => string 'new' (length=3) 'product_location' => string 'Nottingham' (length=10) 'product_images' => array (size=1) ...
But in my template file I am not sure how to iterate through and call? any help would be great. The below code just returns 'Array'
{% for key=>item in {{ products }} %} <b>{{key}}->{{item}}</b> {%endfor%}
The text was updated successfully, but these errors were encountered: