This is a little confusing, so please bear with me.
SUMMARY: Want to display text ads whose category matches the category of the entry/article upon which it is displayed.
DETAILS: I have two/2 channels: blog and sponsors. They both share the same category group.
Sponsors is a simple channel with title, URL, and teaser/text.
Basically, if the reader is displaying a page of articles belonging to CATEGORY 12 ( test.com/category/12), then display a RANDOM sponsor entry which has also has an assigned category of 12.
If the reader is viewing a single article, display a sponsor which has a category that matches one of the articles categories— keeping in mind that both blog entries and sponsor enries can have many categories assigned.
Finally, if there are no matching records, then display any random sponsor, i.e. we have to display something.
So far, I have a random_sponsor template that basically pulls a random entry with no consideration of category:
<div class="widget widget_text">
<h3>Featured Sponsor</h3>
<p><div class="textwidget"></p>
<p>{exp:channel:entries channel='sponsors' limit='1' dynamic='no' orderby='random' disable='member_data|pagination'}<br />
<b>{title}</b><br />
{sponsor_url}<br />
{sponsor_teaser}<br />
{/exp:channel:entries}</p>
<p><br />
</div><br />
</div>
Can it be done?