|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
dazlerd Smarty n00b
Joined: 20 Aug 2009 Posts: 1
|
Posted: Thu Aug 20, 2009 2:32 pm Post subject: php array in javascript in smarty template |
|
|
Hi
I have a set of javascript functions that use an array to show the images of manufacturers.
photos[] = etc
I have added the following {literal} around the <script> tags and the code now works fine.
{literal}
<script type="text/javascript">
</script>
{/literal}
But, the array needs to be dynamic so is created in a php include file.
I use the result from this php function and pass it into the following
$smarty->assign('filter_package_manufacturer', filter_package_manufacturer_smarty(0, $id,true));
which I use to show the section.
So how do I pass the php array into the template file and use as javascript.?
I have tried the following but nothing shows.
document.write( <? print_r {$filter_package_manufacturer[1].logo_url};?>);
Any help would be great thanks
Darren |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Aug 21, 2009 7:54 pm Post subject: |
|
|
Instead of using {literal} tags, use {ldelim} and }{rdelim} in place of javascript curly braces {}. Then you can use smarty tags as usual in your javascript. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|