Banners based on category?

I am setting up an ad banner just before the {$mid_data} in the tiki.tpl file in my site.

I am doing this so a banner shows up in every page of the site just before the content.

The problem is I would like to use different banner zones for each category of my site.

Here is what I am doing:

{if $categ_info.name ne ''}
{banner zone='{$categ_info.name}'}
{banner zone='Default'}

The first problem is the $categ_info.name variable (which seems to be used in the header.tpl) seems to be always empty, is there a more reliable variable that can be accessed to determine the content category? BTW: The {CATPATH(top=>no)}{CATPATH} does not seem to work in the tiki.tpl?

The second problem I may encounter is using {} tags within {} tags, I am guessing that is not going to work, how would I get around that?

There may also be a third problem to this in the future, for now my categories in my site have no sub categories and only one category per item if any. So using category names as zone names for banners will work. However if in the future I may like to have more than one category for an item or sub categories, how would the banner plugin handle that?

After manually tracing through php and tpl files (and lots of banging head on wall), I finally figured it out!

{* Start dynamic ad banner *}
{if !$catp}{banner zone='Default'}
{foreach name=u key=k item=i from=$catp}
{if $i eq 'MyZone'}
{banner zone='MyZone'}
{banner zone='Default'}
{* End dynamic ad banner *}

Note: if a page has more than one 'category', this may stack banners on your page, however when I had more than one {banner} on a wiki page it only displayed the first instance of the {banner}.

Not bad for a guy that a week ago thought that a 'smarty' was a single colorful sugar-coated chocolate confectionery (Smarties). :-)

Aw c'mon, I thought is was funny...

Maybe someone could still help me with this one... Sort external RSS feed to display on Wiki?

Well I tried to edit a type-o:

'Aw c'mon, I thought is was funny...'

supposed to be

'Aw c'mon, I thought it was funny...'

however I get this instead:

Notice: this variable may not be empty: $_POST%22thread_sort_mode%22

Well I thought that I figured it all out (it was a late night), it seems that $catp works just great if you stick to Wiki pages, as soon as you go to gallery or forum, or anywhere else, the $catp holds no value. :-(

So the hunt is on once again for that variable that will report the displayed page category no matter where you go on the site. If you know where is or how to get the displayed page category no matter the page type, please let me know.

BTW: I still can't edit my posts on this site?

Thanks for the reply, I tried that before and just to make sure, I C&P your code into my tiki.tpl and tried it again with the same result as my method.

Works as long as you are viewing a Wiki page, as soon as you view some other content (gallery, forum, directory, etc.) the result is blank.

In the meanwhile I am also trying other ways to retrieve Tiki page category value. Any other ideas still welcome.