Welcome Guest, Not a member yet? Register   Sign In
Template parser - add some conditions
#2

[eluser]Michael Wales[/eluser]
Most people don't use the template parsing - we just use straight PHP. I'll post some sample code below, but I would like to mention if you don't know what type of file your user has uploaded until it's time to display that file - you may want to look into how you've developed your application a bit. Without knowing about your application it's hard to making recommendations.

Using the alternate syntax since I prefer it in view files:
Code:
<?php if (substr($filename, -3) === 'jpg'): ?>
  <img src="&lt;?php echo $filename; ?&gt;" />
&lt;?php elseif (substr($filename, -3) === 'swf'): ?&gt;
  &lt;object src="&lt;?php echo $filename; ?&gt;"&gt;&lt;/object>
&lt;?php endif; ?&gt;


Messages In This Thread
Template parser - add some conditions - by El Forum - 10-08-2009, 04:51 AM
Template parser - add some conditions - by El Forum - 10-08-2009, 06:36 AM
Template parser - add some conditions - by El Forum - 10-08-2009, 06:38 AM
Template parser - add some conditions - by El Forum - 10-08-2009, 07:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB