Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

HELP how can I do this

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
fermin1989
Smarty n00b


Joined: 01 Feb 2018
Posts: 1

PostPosted: Thu Feb 01, 2018 3:08 am    Post subject: HELP how can I do this Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Feb 01, 2018 2:19 pm    Post subject: Reply with quote

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
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Fri Feb 02, 2018 11:48 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP