<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>BinaryKitten&#039;s Development Dropbox &#187; smarty</title>
	<atom:link href="http://binarykitten.com/tag/smarty/feed" rel="self" type="application/rss+xml" />
	<link>http://binarykitten.com</link>
	<description>Curently a work in progress. Please be patient</description>
	<lastBuildDate>Thu, 27 Oct 2011 21:49:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>php: smarty assign content plugin</title>
		<link>http://binarykitten.com/dev/php/smarty-templates/83-php-smarty-assign-content-plugin.html</link>
		<comments>http://binarykitten.com/dev/php/smarty-templates/83-php-smarty-assign-content-plugin.html#comments</comments>
		<pubDate>Mon, 12 Jan 2009 19:27:18 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[Smarty]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[smarty]]></category>

		<guid isPermaLink="false">http://binarykitten.jkrswebsolutions.co.uk/?p=83</guid>
		<description><![CDATA[I needed to assign a block of content to a variable instead of just a value.. so i set about creating this plugin function smarty_block_assign_content($params, $content, &#38;$smarty) { $smarty = clone($smarty); //Copy the original class, so there&#039;s no garbage variables after we finish if(!isset($content)) return; if (!isset($params[&#039;var&#039;])) { $smarty-&#62;trigger_error(&#34;assign_content: missing &#039;var&#039; parameter&#34;, E_USER_WARNING); return; } [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to assign a block of content to a variable instead of just a value.. so i set about creating this plugin</p>
<pre class="brush: php">
function smarty_block_assign_content($params, $content, &amp;$smarty)
{
        $smarty = clone($smarty); //Copy the original class, so there&#039;s no garbage variables after we finish
        if(!isset($content))
                return;
        if (!isset($params[&#039;var&#039;])) {
                $smarty-&gt;trigger_error(&quot;assign_content: missing &#039;var&#039; parameter&quot;, E_USER_WARNING);
                return;
        }

        //Compile content to ensure all smarty tags get processed
        $smarty-&gt;assign($params[&#039;var&#039;], $content);
                $smarty-&gt;assign($k, $v);
        return ;
}
</pre>
<p>example of usage: </p>
<pre class="brush: html">
{assign_content var=&#039;menu&#039;}
  {foreach from=$menus.cats-&gt;children item=&#039;cat&#039;}
  &lt;div class=&quot;item{if $cat-&gt;active || $cat-&gt;expanded}_select{/if}&quot;&gt;
    &lt;div class=&quot;arrow&quot;&gt;&lt;/div&gt;
    {if !$cat-&gt;active}&lt;a href=&quot;{$cat-&gt;link}&quot;&gt;{/if}{$cat-&gt;text}{if !$cat-&gt;active}&lt;/a&gt;
    {/if}
  &lt;/div&gt;
  {if $cat-&gt;children|<a href="http://twitter.com/count">@count</a> ne 0 || $cat-&gt;expanded}
    {foreach from=$cat-&gt;children item=&#039;subCat&#039;}
      &lt;div class=&quot;subitem{if $subCat-&gt;active}_select{/if}&quot;&gt;
        &lt;div class=&quot;arrow&quot;&gt;&lt;/div&gt;
      {if !$subCat-&gt;active}&lt;a href=&quot;{$subCat-&gt;link}&quot;&gt;{/if}{$subCat-&gt;text}{if !$subCat-&gt;active}&lt;/a&gt;{/if}
      &lt;/div&gt;
    {/foreach}
  {/if}
  {/foreach}
{/assign_content}
</pre>
<p>This will set the code we used to generate the menu and assign it to $menu for later use.<br />
Hope you find as usefull</p>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.com/dev/php/smarty-templates/83-php-smarty-assign-content-plugin.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

