JSON

Smarty

{json url="./skin/reboot/custom/json/sample.json" assign=people}
{foreach from=$people item=p name=p}
{if $smarty.foreach.p.first}<div class="row">{/if}
<div class="col-6 col-md-3 text-center">
<div class="card shadow-sm p-3 mb-4">
<h4>{$p->name}</h4>
<p class="mb-2"><img class="lazyload img-fluid rounded-pill shadow" src="{$AltImagesDir}/spacer.gif" data-src="{$p->avatar}" alt="{$p->name}" width="80" height="80"></p>
<p class="mb-2">{$p->job}</p>
<p class="mb-2">Age: {$p->age}</p>
{if $p->likes}<p class="mb-2"><small>Likes: {foreach from=$p->likes item=like name=l}{$like}{if !$smarty.foreach.l.last}, {/if}{/foreach}</small></p>{/if}
</div>
</div>
{if $smarty.foreach.p.last}</div>{/if}
{/foreach}

Result

John

John

Developer

Age: 32

Likes: PHP, HTML, JS, CSS

Mary

Mary

Designer

Age: 28

Likes: Photoshop, Sketch

Dave

Dave

Support

Age: 45

Likes: Football, Guitar

Jane

Jane

Accounts

Age: 32

Likes: Piano, Violin

Recently Viewed