First: Don't use PHP in smarty templates. It's a template engine so any actual 'work' should be done outside.
Second: Your signature shows 4.1 so it should be in that category and not 4.2/4.3
Third: Try something like this:
Code:
{*
show the url for a baseline
*}
{$canonical_url}
{if $main neq 'product'}
<div class="menu-dialog{if $additional_class} {$additional_class}{/if}">
<div class="title-bar valign-middle{if $link_href} link-title{/if}">
{strip}
{if $link_href}
<span class="title-link">
<a href="{$link_href}" class="title-link"><img src="{$ImagesDir}/spacer.gif" alt="" /></a>
</span>
{/if}
<img class="icon ajax-minicart-icon" src="{$ImagesDir}/spacer.gif" alt="" />
<h2>{$title}</h2>
{/strip}
</div>
<div class="content">
{$content}
</div>
</div>
{/if}