Image

Imagetiger_yamato wrote in Imagephp

I'm starting to really hate the Smarty template engine.

So I understand most of the syntax, and I've got this script that allows the upload of 8 images, and then it displays them back.


{if $thread.images}
{* tyam - let's avoid more template breaking *}
{counter name="imgcount" assign="imgcount" start="0"}
{foreach from=$thread.images item=it}
<div class="imgbox">
{* tyam - |filetrunc added to truncate image filenames and prevent template breaking *}
	<div class="filesize">File: <a href="{$THurl}images/{$thread.imgidx}/{$it.name}" target="_blank">{$it.name|filetrunc}</a><br />
	(<em>{$it.fsize} K, {$it.width}x{$it.height}{if $it.anim}, α{/if}</em>)</div>
		<a href="{$THurl}images/{$thread.imgidx}/{$it.name}" target="_blank">
		<img src="{$THurl}images/{$thread.imgidx}/{$it.tname}" width="{$it.twidth}" height="{$it.theight}" alt="{$it.name}" class="thumb" /></a>
</div>
{counter name="imgcount"}
{/foreach}
{/if}



The problem with this is that it tries to put them all on the same line, with the results being less than pleasing.

Now, I can't for the life of me figure out, using Smarty syntax, how to replicate this (poorly written and from at least 3 years ago) php code:

      echo "<table width=100% border=0 cellspacing=0 cellpadding=0>";
      echo "<tr>";
      for($i=0; $i<$num_rows; $i++)
      {
        if ($counter == 0 or $counter == 6) { $counter = 1 ; }
        if ($counter == 1)
        {
          if ($rowcount ==0 or $rowcount == 5)
          {
            echo "</tr>";
            $rowcount = 1;
            $counter=1;
          }
          echo "</tr><tr>";
          ++$rowcount;
        }
        ++$counter;
        echo "<td width=20% align=center>";
	//do output of image box
        echo "</td>";
        ++$loopid;
        ++$addedid;
      }
      echo "</tr></table>";




I'm really starting to regret using Smarty but I've gone too far into development to change my mind now. D:


Desired output is:

[pic] [pic] [pic] [pic]
[pic] [pic] [pic] [pic]
Any text that was included in the text box