ballhogjoni Posted May 24, 2008 Share Posted May 24, 2008 I want to assign the array $errormessage[] to output using my smarty foreach loop in my tpl file. I am not getting an error but my screen goes blank. I assume there is an error but I can't figure it out. How can I assign this array to the smarty 'errors' variable so I can use the foreach loop in the tpl file to print the data? Here is my code: PHP File $errorMessage = array(); $errorMessage[] = "sadlkjf"; $errorMessage[] = "woirdof"; $errorMessage[] = "lkjsdf89ewl"; $smarty->assign('errors', $errorMessage); TPL File {if $errors}<p style="text-align:center; color:#FF0000;"><ul>{foreach from=$errors key=foo item=message}<li>{$message}</li>{/foreach}</ul></p>{/if} Thanks in advance Link to comment https://forums.phpfreaks.com/topic/107042-solved-smarty-help-with-assigning-an-array/ Share on other sites More sharing options...
Darklink Posted May 24, 2008 Share Posted May 24, 2008 Start debugging. {if $errors} There are errors {else} There are no errors {/if} At least you will have something that will show up! If it doesn't, you have a problem. From the looks of it, if I remember rightly with Smarty it looks correct. But just try that first. Link to comment https://forums.phpfreaks.com/topic/107042-solved-smarty-help-with-assigning-an-array/#findComment-548816 Share on other sites More sharing options...
ballhogjoni Posted May 24, 2008 Author Share Posted May 24, 2008 the issue is within the php file not the tpl. ie the assigning of the smarty variable. thanks for the reply Link to comment https://forums.phpfreaks.com/topic/107042-solved-smarty-help-with-assigning-an-array/#findComment-548851 Share on other sites More sharing options...
ballhogjoni Posted May 24, 2008 Author Share Posted May 24, 2008 ok I am officially an idiot. I am getting the blank screen becasue I forgot to display the tpl file. Every thing works now. Link to comment https://forums.phpfreaks.com/topic/107042-solved-smarty-help-with-assigning-an-array/#findComment-548889 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.