title: How do I write Smarty Block Plugins that loop over database records
body: <p>Given a Category (parent) and Product (child) tables in a database, say, I want to create Smarty Block Plugins that would enable template snippets similar to this:</p>
  
  <pre><code>{products category="Some Category"}
      &lt;h1&gt;{products_name}&lt;/h2&gt;
      &lt;p&gt;{products_description}&lt;/p&gt;
  {/products}
  </code></pre>
  
  <p>I believe plugins like these would help avoid repeated chunks of code that read a database and do a smarty-assign on the result in my controller. </p>
  
  <p>I know how to write this as a smarty function. But I am looking for a block version to give the template designer the flexibility to style the individual columns in whatever way he wants. I am a long-time Perl programmer and new to Smarty. Perl users will recognise something like this in the Movable Type Templating System for example, and I wonder if a smarty version is possible.</p>
  
  <p>Is something like this possible in Smarty at all? Is it a good thing to make a DB call from inside a smarty plugin? </p>