This is more of a how to php question that is currently stumping me.
I’ve got the Invocation code here:
<?php
define('MAX_PATH', '/pathto/openads');
if (@include_once(MAX_PATH . '/www/delivery/alocal.php')) {
if (!isset($phpAds_context)) {
$phpAds_context = array();
}
$phpAds_raw = view_local('', 1, 0, 0, '', '', '0', $phpAds_context);
echo $phpAds_raw['html'];
}
?>
and I’ve got a plugin I’ve written for my site that can insert html after the third paragraph:
class Formatstory {
var $return_data;
function Formatstorybeta($str = '')
{
global $TMPL;
if ($str == '')
{
$str = $TMPL->tagdata;
}
$str = preg_replace('/', $str, 1);
$save = explode('', $str);
$count = 1;
foreach ($save as $a){
if ($count == 3){
(clever block ad here)
}
$rtn .= $a . '';
$count = $count + 1;
}
$this->return_data = $rtn;
}
}
How do I get the code for the ad into this string that I’m building? Thoughts?
Chris,
Is there a reason you don’t want to split your entries into two seperate custom fields?
Seems like it would be easier to simply do:
{custom_field_1}
AD CODE HERE
{custom_field_2}
If thats not a solution you can’t pass a multi line piece of code to a plugin using a parameter. So you have to have the invocation code either already in your plugin or else between the plugin tags in the template.
If you put it between the plugin tags in the template you could use a tag pair within the plugin tags:
{ad_bloc}INVOCATION CODE HERE{/ad_bloc}
And have your plugin remove it from the template and then replace it in the correct spot after paragraph 3 like you already have worked out.
Jamie
I’ve got a bit of a solution already (its been a while since I started this thread) using a plug-in and this bit of code:
$save = explode('', $str);
That way, I can take a given iteration and insert by desired code and return it.
I’m not a PHP developer by any means, so while I think I have it working correctly on the EE side, OpenAds is now wonky when I call it. and any other ad on the same page.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.