|
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 |
fermin1989 Smarty n00b
Joined: 01 Feb 2018 Posts: 1
|
Posted: Thu Feb 01, 2018 3:08 am Post subject: HELP how can I do this |
|
|
Hello, I need help, I will try to explain:
I use a system that has Smarty, it uses {{}} to show the example variables $ data
what I need is to show a value that is in an array, would be $ data.formats..mp4.file_url
The problem I think is that the .mp4 does not have a name in front of it and having ... causes a blank page error.
Is there any way to print this value?
THANK YOU |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Thu Feb 01, 2018 2:19 pm Post subject: |
|
|
You can add {{debug}} to a template to see all the variables passed to it more clearly.
Alternatively, to see the structure of an array in Smarty, I'm using this simple trick:
Code: | <pre>{{$data.formats|print_r:true}}</pre> |
Do note that it is only reliable for seeing the structure, not actual exact values, as it prints the data. |
|
Back to top |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Fri Feb 02, 2018 11:48 pm Post subject: |
|
|
If you are getting a blank page, then adding the debug command to the template isn't going to give anything more than what you already have -- a blank page with PHP having crashed.
If you have access to the PHP code populating the template, then right before the $smarty->fetch() or $smarty->display() statement in the PHP script, which renders the template, add this statement:
die('<pre>'.print_r($smarty->getTemplateVars(),true).'</pre>'); |
|
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
|