I want to print list of image address in jquery function using php(adodb) and smarty.
i need to this :
$.lightbox(["/media/photos/tmb/4.jpg", "/media/photos/tmb/3.jpg", "/media/photos/tmb/6.jpg"]);
i try with this (just simple for test) :
{/literal} {if $photos} $.lightbox(["{"\", \""|implode:$photos}"]); {/if}{literal}
result is :
$.lightbox(["Array", "Array", "Array", "Array", "Array", "Array", "Array", "Array", "Array", "Array", "Array"]);
Actually, i need to replace array with images address.
images address (dynamic loop) :
{$relative}/media/photos/tmb/{$photos[i].PID}.jpg
without jquery function, i list images with this methods :
{if $photos}
{section name=i loop=$photos}
{$relative}/media/photos/tmb/{$photos[i].PID}.jpg
{/section}
{/if}
php code:
$sql = "SELECT PID, caption FROM photos WHERE AID = " .$aid. " AND status = '1' LIMIT " .$limit;
$rs = $conn->execute($sql);
$photos = $rs->getrows();
$smarty->assign('photos', $photos);
how to print list for my need? can i?
The easiest thing to do is assign the array to your template, and use
json_encode(). I don’t use Smarty very often, but I believe you can just do:Edit: Now that you’ve finally told us what your array contains:
Here’s what you need to do. In your controller:
In your template, you can access the array via
$photoFileNamesJSON. The next time you post a question, please include all of the information from the start. It will be much easier to provide a more specific answer, if you are specific with your question.