Apr

17

2010

0

comments

Banner Advertising With ExpressionEngine

I’m currently building a magazine site for a client which will have advertising in the sidebar. To implement this advertising I used the method detailed in the Subvert.ca blog How to build your own banner advertising system with ExpressionEngine and Google Analytics This was really easy to implement. However I wanted to do a little more.

Since campaigns may expire and it’s possible that there may not be a full complement of live ads on the site at one time I decided to add dummy ads to the site that will only appear when there are not enough paid ads. To do this I used the” loop plugin”:http://www.putyourlightson.net/projects/loop and a series of conditionals. the advertising here is block of four – 125 ads where the weblog:entries tag has a limit=“4” The following code is placed just before the closing weblog:entries tag in the tutorial mentioned above and voila blank ads to complete the block.

{if no_results}
    {exp
:for_loop start="1" end="4" increment="1"}    
        
<a href="{site_url}site/contact/"><img src="{interface}images/ad125x125.jpg" alt="advertise with us" height="125" width="125" /></a>
    
{/exp:for_loop}
{
/if}
{if count
=="1" AND total_results=="1"}
    {exp
:for_loop start="1" end="3" increment="1"}    
        {if {loop_count} 
>="{count}"}<a href="{site_url}site/contact/"><img src="{interface}images/ad125x125.jpg" alt="advertise with us" height="125" width="125" class="{switch='ad125-left|ad125-left|ad125-right|ad125-left'}"/></a>{/if}
    {
/exp:for_loop}
{if
:elseif count=="2" AND total_results=="2"}
    {exp
:for_loop start="1" end="3" increment="1"}    
        {if {loop_count} 
>="{count}"}<a href="{site_url}site/contact/"><img src="{interface}images/ad125x125.jpg" alt="advertise with us" height="125" width="125" class="ad125-left"/></a>{/if}
    {
/exp:for_loop}
{if
:elseif count=="3" AND total_results=="3"}
    {exp
:for_loop start="1" end="3" increment="1"}    
        {if {loop_count} 
>="{count}"}<a href="{site_url}site/contact/"><img src="{interface}images/ad125x125.jpg" alt="advertise with us" height="125" width="125" /></a>{/if}
    {
/exp:for_loop}
{
/if} 

You can see a screen shot of my dev site below.

image

Tags: expressionengine, code, advertising,

There are 0 Comments about this post

Commenting is not available in this channel entry.