Pligg CMS Forums


Go Back   Pligg CMS Forum > Pligg Help > Customization Assistance



[SOLVED] Category specific banner ad targeting (story.php / story_center.tpl)

Questions about customizing your Pligg site.


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-07-2009, 03:13 PM
Donor
Donation Level 2 
 
Join Date: Jul 2008
Posts: 28
[SOLVED] Category specific banner ad targeting (story.php / story_center.tpl)

I've searched the forums, tried a whole bunch of little hacks, but I have yet to find a solution for the idea I want to implement.

I'm not much of a coder, so I thought maybe someone from the forum could help. Here's an example of what I want to do.

Category 1 - Birds
Category 2 - Cats
Category 3 - Dogs

Let's say I have a site with categories on many different types of pets. I don't, but maybe that's a good idea? Who knows! Anyway, when a person clicks on a story from the Birds category, say "Bird attacks owner with tiny machete", I want a bird-specific ad to show up on the story page.

It would look like this.

Story

Bird Food Ad

Comments


Now, let's say the person surfed over to the story "Cat saves local fireman from tree", which is in the Cats category. Now I want a cat specific banner ad to pop up.

I know I could throw an adsense block right there and I know where to put it in story_center.tpl, so the location is not an issue. I'm more interested in targeting some affiliate programs with this idea.

I've tried writing some conditional {if} statements in story_center.tpl after {$the_story}, but I'm having no luck with getting any category variables to play along with my ruse.

For example:

{if $category_id eq '1' }
ad code
{/if}

Did not produce the desired result. I've tried $category_name, $category_safe_name, $link_category_id, and a few others.

Hopefully, someone understood my meager dream of targeted ads and will come to my rescue.

Thanks!
Reply With Quote
Sponsor
  #2 (permalink)  
Old 01-07-2009, 03:38 PM
chuckroast's Avatar
Coder/Designer
Pligg Version: 1.0
Pligg Template: Shredit
 
Join Date: Jun 2006
Location: PA
Posts: 3,394
I haven't tried this and have no idea if this would work but I would try something this in link_summary.tpl

Code:
{if $pagename eq "story"}
{if $cat_array[thecat].dogs}
<----Advertisement about dogs----->
{/if}{/if}

{if $pagename eq "story"}
{if $cat_array[thecat].birds}
<---Advertisement about birds------>
{/if}{/if}

and so on...


Thank this developer

Get the Pligg 1.0 Module Pack and more ---> download here




Reply With Quote
  #3 (permalink)  
Old 01-07-2009, 03:55 PM
Yankidank's Avatar
Coder/Designer
Pligg Version: SVN
Pligg Template: Wistie
 
Join Date: Dec 2005
Location: Ocala, FL
Posts: 2,916
Send a message via AIM to Yankidank Send a message via Skype™ to Yankidank
I'm not familiar with Chucks method, but I wrote up working code for 1.0 in the wiki a week ago:
Pligg Categories

Need a Web Host ?
Save up to $84
when you purchase hosting from Dreamhost.com.
Use the coupon code PLIGG when buying a web hosting package from Dreamhost.com
Reply With Quote
  #4 (permalink)  
Old 01-07-2009, 04:52 PM
chuckroast's Avatar
Coder/Designer
Pligg Version: 1.0
Pligg Template: Shredit
 
Join Date: Jun 2006
Location: PA
Posts: 3,394
Yeah, you can probably also do it like

{if $pagename eq "story"}
{if $request_category eq "dogs"}
<----Advertisement about dogs----->
{/if}{/if}

{if $pagename eq "story"}
{if $request_category eq "birds"}
<---Advertisement about birds------>
{/if}{/if}

and so on...


Thank this developer

Get the Pligg 1.0 Module Pack and more ---> download here




Reply With Quote
  #5 (permalink)  
Old 01-07-2009, 06:53 PM
Donor
 
Join Date: Jul 2008
Posts: 28
I tried both of those methods but they didn't work. I tried the code (both variations) in link_summary and story_center, but so far no combination has produced the desired result. I tried double quotes and single quotes around the category name and I tried using the category_safe_name, but no luck.

Can you give me a specific idea of where to place the code? I will gladly make a donation to the pligg cause if you can help me with this trick!

Thanks!
Reply With Quote
  #6 (permalink)  
Old 01-07-2009, 07:12 PM
chuckroast's Avatar
Coder/Designer
Pligg Version: 1.0
Pligg Template: Shredit
 
Join Date: Jun 2006
Location: PA
Posts: 3,394
I just tried this on my site and it works. Using category ID numbers. Lets say the category dogs has the Id number of 2

{if $pagename eq "story"}
{if $category_id eq "2"}
<----Advertisement about dogs----->
{/if}{/if}

Repete for each category.

Then put the code in link_summary.tpl just above
{checkActionsTpl location="tpl_link_summary_end"}

Good Luck


Thank this developer

Get the Pligg 1.0 Module Pack and more ---> download here




Reply With Quote
  #7 (permalink)  
Old 01-07-2009, 10:13 PM
Donor
 
Join Date: Jul 2008
Posts: 28
Quote:
Originally Posted by chuckroast View Post
I just tried this on my site and it works. Using category ID numbers. Lets say the category dogs has the Id number of 2

{if $pagename eq "story"}
{if $category_id eq "2"}
<----Advertisement about dogs----->
{/if}{/if}

Repete for each category.

Then put the code in link_summary.tpl just above
{checkActionsTpl location="tpl_link_summary_end"}

Good Luck
Perfect! This is exactly what I needed. You can go ahead and do a [SOLVED] on this one.
Reply With Quote
Reply

Tags
ads, affiliate, category, specific

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pligg Categories Yankidank Wiki Articles 1 12-17-2008 10:10 AM
How to show category keywords as text on the site? gnalkit Customization Assistance 4 11-26-2008 05:17 AM
Control of meta description - categories Divisive Cotton Suggestions 64 11-23-2008 07:37 PM
[SOLVED] Upcoming Specific Category RSS Feeds blaze General Help 2 09-23-2008 09:10 AM

Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Use the coupon code PLIGG at Dreamhost.com to receive a discount of up to $84.00 Make a donation to support Pligg CMS development