Skip to Main Content

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.

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 and a series of conditionals. the advertising here is block of four 125x125 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"}
&nbsp; <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"}
&nbsp; {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"}
&nbsp; {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"}
&nbsp; {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.

screenshot