PDA

View Full Version : Adding PHP Code (ad network) to directory header or footer


ozegreatdeals
11-11-2006, 09:24 AM
Hi,
I have asked a couple of mates to help me with this but so far they have not been able to get it to work.

I need to add the following code to my site to display some text adverts which a advertiser has purchased:
<?php
$fp = @fsockopen("www.linkworth.com", "80",$errno, $errstr, $timeout="5");
if($fp)
{
require 'http://www.linkworth.com/act/partner/rotating_ads/inclusion_links.php?prt_website_id=852&prt_website_link_placement_location=3&prt_website_link_placement_id=2143&link_format=1';
}
?>

Here is what is currently in the top_bar.tpl file:
{strip}
<div id="nav">
<ul>
<li><a href="{$smarty.const.DOC_ROOT}/index.php">{l}Homepage{/l}</a></li>
<li><a href="{$smarty.const.DOC_ROOT}/submit.php">{l}Suggest URL{/l}</a></li>
<li><a href="{$smarty.const.DOC_ROOT}/index.php?p=d">{l}Latest Links{/l}</a></li>
<li><a href="{$smarty.const.DOC_ROOT}/index.php?p=h">{l}Top Hits{/l}</a></li>
</ul>
</div>
{* Left(!!) part of the top bar *}
<div id="location">
{* Display current path *}
{assign var="current_path" value=""}
{foreach from=$path item=cat name=path}
{assign var="current_path" value="`$current_path``$cat.TITLE_URL`/"}
{if not $smarty.foreach.path.first} &raquo; {/if}
{if not $smarty.foreach.path.last}
<a href="{if $smarty.const.ENABLE_REWRITE}{$current_path}{else} index.php?c={$cat.ID}{/if}">{$cat.TITLE}</a>
{else}
{$cat.TITLE}
{/if}
{/foreach}

</div>
{literal}
<?php

$fp = @fsockopen("www.linkworth.com", "80",$errno, $errstr, $timeout="5");

if($fp)

{

require 'http://www.linkworth.com/act/partner/rotating_ads/inclusion_links.php?prt_website_id=852&prt_website_link_placement_location=3&prt_website_link_placement_id=2143&link_format=1';

}

?>
{/literal}
{/strip}

Does anyone have any ideas on how to place the code so it will work?

Drew.

proprod
11-11-2006, 09:33 AM
If you're adding to a .tpl file, try this:

Content visible to registered users only.

ozegreatdeals
11-11-2006, 09:42 AM
Content visible to registered users only.

Hi,
That got the text code to display on the site but not the actual text link - see ozegreatdeals.com.

it displays the code as text, here is the updated .tpl file, let me know if I did something wrong:
{strip}
<div id="nav">
<ul>
<li><a href="{$smarty.const.DOC_ROOT}/index.php">{l}Homepage{/l}</a></li>
<li><a href="{$smarty.const.DOC_ROOT}/submit.php">{l}Suggest URL{/l}</a></li>
<li><a href="{$smarty.const.DOC_ROOT}/index.php?p=d">{l}Latest Links{/l}</a></li>
<li><a href="{$smarty.const.DOC_ROOT}/index.php?p=h">{l}Top Hits{/l}</a></li>
</ul>
</div>
{* Left(!!) part of the top bar *}
<div id="location">
{* Display current path *}
{assign var="current_path" value=""}
{foreach from=$path item=cat name=path}
{assign var="current_path" value="`$current_path``$cat.TITLE_URL`/"}
{if not $smarty.foreach.path.first} &raquo; {/if}
{if not $smarty.foreach.path.last}
<a href="{if $smarty.const.ENABLE_REWRITE}{$current_path}{else} index.php?c={$cat.ID}{/if}">{$cat.TITLE}</a>
{else}
{$cat.TITLE}
{/if}
{/foreach}

</div>
{literal}
{php}
$fp = @fsockopen("www.linkworth.com", "80",$errno, $errstr, $timeout="5");
if($fp)
{
require 'http://www.linkworth.com/act/partner/rotating_ads/inclusion_links.php?prt_website_id=852&prt_website _link_placement_location=3&prt_website_link_placem ent_id=2143&link_format=1';
}
{/php}
{/literal}
{/strip}

Drew.

proprod
11-11-2006, 09:49 AM
Take out {literal} and {/literal}

ozegreatdeals
11-11-2006, 10:44 AM
Content visible to registered users only.

Hi,
When i remove the literal bits i get this error message, is this from the advert end?

Fatal error: main(): Failed opening required 'http://www.linkworth.com/act/partner/rotating_ads/inclusion_links.php?prt_website_id=852&prt_website _link_placement_location=3&prt_website_link_placem ent_id=2143&link_format=1' (include_path='.:/usr/lib/php:/usr/local/lib/php:/home/oze/public_html/') in /home/oze/public_html/temp/templates/en^%%5D^5D8^5D889347%%top_bar.tpl.php on line 11

Drew.