Need help with adding adsense to phpld

Discussion in 'PHP' started by procrastinator, Apr 5, 2007.

  1. #1
    I want to have an adsense ad just after the category items
    the link for the directory

    I have a seperate tpl file for adsense, and can add it by adding the code
    {include file="ad.tpl"} , i have doen it succesfully with the header.

    however , i am unable to place it exactly below the category items. need some help with it.

    this is the main.tpl file

    {* Calculate title from path *} {capture name="title"} {if count($path) > 1} - 
    {/if} {foreach from=$path item=category name=path} {if $smarty.foreach.path.iteration 
    gt 2} > {/if} {if not $smarty.foreach.path.first} {$category.TITLE} {/if} {/foreach} 
    {/capture} {strip} {if $title_prefix} {assign var="in_page_title" value=$title_prefix|cat:$category.TITLE} 
    {else} {assign var="in_page_title" value=$category.TITLE} {/if} {assign var="description" 
    value=$category.DESCRIPTION} {include file="header.tpl"} {include file="top_bar.tpl"} 
    <table width="776" border="0" align="center" cellpadding="0" cellspacing="0" style="margin-top: 5px;">
      <tr> 
        <td width="181" valign="top">{include file="sidebar.tpl"}</td>
        <td width="13" valign="top" background="{$smarty.const.DOC_ROOT}/images/separator.gif">&nbsp;</td>
        <td width="582" valign="top">{* Calculate the number of categories per row 
          *} {php} $this->assign('cats_per_col', ceil(count($this->get_template_vars('categs')) 
          / CATS_PER_ROW)); {/php} {if $cats_per_col > 15} {php} $this->assign('cats_per_col', 
          ceil(count($this->get_template_vars('categs')) / (CATS_PER_ROW + 1))); {/php} 
          {/if} {* Categories *} {if !empty($categs)} 
          <div class="categories"> 
            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="bars">
              <tr> 
                <td>Categories</td>
              </tr>
            </table>
            <table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin-bottom: 15px;">
              <tr> {foreach from=$categs item=cat name=categs} {if ($smarty.foreach.categs.iteration 
                mod $cats_per_col eq 1 and $cats_per_col gt 1) or $smarty.foreach.categs.first} 
                <td valign="top">{/if} 
                  <h1><a href="{if $smarty.const.ENABLE_REWRITE}{$cat.TITLE_URL|escape}/{else}index.php?c={$cat.ID}{/if}">{$cat.TITLE|escape}</a>{if 
                    $smarty.const.CATS_COUNT} <span class="count">({$cat.COUNT})</span>{/if}</h1>
                  {* Display subcategories *} {if !empty($cat.SUBCATS)} 
                  <p class="subcats"> {foreach from=$cat.SUBCATS item=scat name=scategs} 
                    <a href="{if $smarty.const.ENABLE_REWRITE}{$cat.TITLE_URL|escape}/{$scat.TITLE_URL|escape}/{else}index.php?c={$scat.ID}{/if}"> 
                    {$scat.TITLE|escape}</a>, {/foreach}...</p>
                  {/if} {if ($smarty.foreach.categs.iteration mod $cats_per_col eq 
                  0 and $cats_per_col gt 1) or $smarty.foreach.categs.last}</td>
                {/if} {/foreach} </tr>
            </table>
          </div>
          {/if} {if $smarty.const.FTR_ENABLE == 1 and isset($feat_links) and !empty($feat_links)} 
          <div class="feat_links"> 
            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="fbars">
              <tr> 
                <td>Featured Links</td>
              </tr>
            </table>
            <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr> 
                <td>{foreach from=$feat_links item=link name=links} {include file="flink.tpl" 
                  link=$link} {/foreach}</td>
              </tr>
            </table>
            
          </div>
          {/if} {* Links heading and sorting*} {if ($qu or $category.ID gt 0 or $p) 
          and isset($links) and !empty($links)} 
          <div id="links"> 
            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="bars">
              <tr> 
                <td width="39%">Regular Links</td>
                <td width="70%" align="right">{if not $p}<span class="small">{l}Sort by{/l}: {if $smarty.const.ENABLE_PAGERANK and $smarty.const.SHOW_PAGERANK}{if 
                  $sort eq 'P'}<span class="sort"> {l}PageRank{/l}</span>{else}<a href="?s=P{if not $smarty.const.ENABLE_REWRITE}&amp;c={$category.ID}{/if}{if $qu}&amp;q={$qu}{/if}{if !empty($p)}&amp;p={$p}{/if}"> 
                  {l}PageRank{/l}</a>{/if} | {/if} {if $sort eq 'H'} <span class="sort">{l}Hits{/l}</span>{else} <a href="?s=H{if not $smarty.const.ENABLE_REWRITE}&amp;c={$category.ID}{/if}{if $qu}&amp;q={$qu}{/if}{if !empty($p)}&amp;p={$p}{/if}">{l}Hits{/l}</a>{/if}{if 
                  $sort eq 'A'} | <span class="sort">{l}Alphabetical{/l}</span>{else} | <a href="?s=A{if not $smarty.const.ENABLE_REWRITE}&amp;c={$category.ID}{/if}{if $qu}&amp;q={$qu}{/if}{if !empty($p)}&amp;p={$p}{/if}">{l}Alphabetical{/l}</a>{/if} 
                  </span>{/if}</td>
              </tr>
            </table>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td>
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="links-bg">
                    <tr> 
                      <td><div id="links">{foreach from=$links item=link name=links} 
                          {include file="link.tpl" link=$link} {/foreach} </div>
                        {/if} </td>
                    </tr>
                  </table></td>
              </tr>
            </table>
          </div>
          <table width="100%" border="0" cellspacing="5" cellpadding="0">
            <tr> 
              <td> <div class="navig"> 
                  <div style="float: right"> {* Pager (not used yet) *} {if $list_total 
                    gt 0} {if $smarty.const.ENABLE_REWRITE} {assign var='url_pattern' 
                    value='?p=$'} {/if} {pager rowcount=$list_total limit=$smarty.const.PAGER_LPP 
                    class_num="" class_numon="a" class_text="" posvar="p" show="page" 
                    txt_next="Next" txt_prev="Previous" shift="1" separator=" " wrap_numon="[|]" 
                    url_pattern="$url_pattern"} </div>
                  {l}Total records:{/l} {$list_total} {/if}</div></td>
            </tr>
          </table></td>
      </tr>
    </table>
    {* Javascript for tracking link clicks *} 
    <script type="text/javascript">
    /* <![CDATA[ */
       var root = '{$smarty.const.DOC_ROOT}';
       {literal}
       var a = document.getElementsByTagName("a");
       for(i = 0; i< a.length; i++)
          if(a[i].id != '')
             a[i].onclick = count_link;
       function count_link() {
          i = new Image();
          i.src= root+'/cl.php?id='+this.id;
          return true;
       }
       {/literal}
    /* ]]> */
    </script>
    {include file="footer.tpl"}
    {/strip}
    Code (markup):
     
    procrastinator, Apr 5, 2007 IP
  2. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #2
    {$scat.TITLE|escape}</a>, {/foreach}...</p>
    {include file="ad.tpl"}

    Above To display just below "sub categories.

    Below to display just below Main category:

    <h1><a href="{if $smarty.const.ENABLE_REWRITE}{$cat.TITLE_URL|escape}/{else}index.php?c={$cat.ID}{/if}">{$cat.TITLE|escape}</a>{if
    $smarty.const.CATS_COUNT} <span class="count">({$cat.COUNT})</span>{/if}</h1>
    {include file="ad.tpl"}

    Not sure what you meant by "category items"...

    Also you are allowed only 3 "adsense" units on 1 page. I think the way you are doing this will show more than that.
    Bye :)
     
    JEET, Apr 5, 2007 IP
    procrastinator likes this.
  3. procrastinator

    procrastinator Peon

    Messages:
    1,718
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    0
    #3
    this is how i want it
    [​IMG]
    ... i managed to have the ad , but

    there is a close icon to the top left of the ad , i am guessing it has something to do with the code.
     
    procrastinator, Apr 5, 2007 IP
  4. MeetHere

    MeetHere Prominent Member

    Messages:
    15,399
    Likes Received:
    994
    Best Answers:
    0
    Trophy Points:
    330
    #4
    I dont think that's related to the code..
    Try to refresh - do you see with text ads ?
     
    MeetHere, Apr 5, 2007 IP
    procrastinator likes this.
  5. procrastinator

    procrastinator Peon

    Messages:
    1,718
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    0
    #5
    MeetHere , is right , lol , i changed to all text and it doesnt appear. thanks a bunch, reps added.
     
    procrastinator, Apr 5, 2007 IP