Why PHP block does not work?

Hello!

Dolphin 7.1.4 + OpenX.

I pasted such code at     _sub_header.html:

<?php

  //<!--/* OpenX Local Mode Tag v2.8.11 */-->

  define('MAX_PATH', '/var/www/opx');

  if (@include_once(MAX_PATH . '/www/delivery/alocal.php')) {

    if (!isset($phpAds_context)) {

      $phpAds_context = array();

    }

//468

    $phpAds_raw['468'] = view_local('', 15, 0, 0, '', '', '0', $phpAds_context, '');

    $phpAds_context[] = array('!=' => 'campaignid:'.$phpAds_raw['468']['campaignid']);

//$phpAds_context[] = array('!=' => 'bannerid:'.$phpAds_raw['4a']['bannerid'])

 

//RUN

$phpAds_raw['RUN'] = view_local('', 18, 0, 0, '', '', '0', $phpAds_context, '');

    $phpAds_context[] = array('!=' => 'campaignid:'.$phpAds_raw['RUN']['campaignid']);

 

//120

$phpAds_raw['120'] = view_local('', 1, 0, 0, '', '', '0', $phpAds_context, '');

    $phpAds_context[] = array('!=' => 'campaignid:'.$phpAds_raw['120']['campaignid']);

  }

  echo $phpAds_raw['468']['html'];

 ?>

After i made PHP block in DeanosTools for HOMEPAGE and pasted there

  echo $phpAds_raw['120']['html'];

Cleaned all caches! Block echo $phpAds_raw['468']['html']; in header is shown but block echo $phpAds_raw['120']['html']; from DeanosTools is not appears at site.

If i put  at _footer.html this code, it works good and i can see both blocks at site:

 <?php echo $phpAds_raw['120']['html']; ?>

Help me please. Where is mistake? Why if i put such code at site templates it works and if i put it at PHP-Block it doesn't?

 

Quote · 29 Aug 2013

PHP Blocks in dolphin are processed using the php eval function.

They cannot contain starting and ending php tags.  Example

This will not work in a php block.

<?php
echo 'Hello World!';
?>

But this will work.

echo 'Hello World!';


Most existing php code cannot simply be dropped into a php block without some rewrites to make it compatible with eval.


https://www.deanbassett.com
Quote · 29 Aug 2013

At php block i inserted just echo $phpAds_raw['120']['html']; without <?php and ?>.   It does not work. Anybody help me please.. What i should change?

Quote · 29 Aug 2013

You need to give us some more details on what you are trying to do.  You don't place php code in the _sub_header.html file.  First step is to remove that from the _sub_header.html and then explain what you need help on doing.

Geeks, making the world a better place
Quote · 29 Aug 2013

Anything under *.html should be using html code, not php.

I can see you complicate things by throwing php codes into an html page in the beginning.

Quote · 29 Aug 2013

I want to integrate OPENX with Dolphin. It works good if i use JS to show ads from OpenX Server, but i want to use PHP. Such code  should generate content for 3 blocks with different content. 

<?php  

define('MAX_PATH', '/var/www/opx');

  if (@include_once(MAX_PATH . '/www/delivery/alocal.php')) {

    if (!isset($phpAds_context)) {

      $phpAds_context = array();

    }

//468

    $phpAds_raw['468'] = view_local('', 15, 0, 0, '', '', '0', $phpAds_context, '');

    $phpAds_context[] = array('!=' => 'campaignid:'.$phpAds_raw['468']['campaignid']);

//$phpAds_context[] = array('!=' => 'bannerid:'.$phpAds_raw['4a']['bannerid'])

 

//RUN

$phpAds_raw['RUN'] = view_local('', 18, 0, 0, '', '', '0', $phpAds_context, '');

    $phpAds_context[] = array('!=' => 'campaignid:'.$phpAds_raw['RUN']['campaignid']);

 

//120  

$phpAds_raw['120'] = view_local('', 1, 0, 0, '', '', '0', $phpAds_context, '');

    $phpAds_context[] = array('!=' => 'campaignid:'.$phpAds_raw['120']['campaignid']);

  }

?>

 

It should be in the page. Also i should call content of each block. I  should paste such code below in places where i want to show ads.

 <?php echo $phpAds_raw['120']['html']; ?> - it is one block

 <?php echo $phpAds_raw['468']['html']; ?> -  it is another block

 <?php echo $phpAds_raw['RUN']['html']; ?> -  it is another one block

It is link to OpenX help http://www.openx.com/docs/tutorials/local%20mode%20tags

I'm sure it is easy to use, but i don't know php and it's my problem ))

Do you have any suggestion?

Quote · 29 Aug 2013

No, what you need to do is to use Deano's Tools and create the php block for each one, then, not including the <?php and ?> add the php code for each one separately in each block.

Geeks, making the world a better place
Quote · 29 Aug 2013

 

No, what you need to do is to use Deano's Tools and create the php block for each one, then, not including the add the php code for each one separately in each block.

I did it, but it does not appears. I inserted WITHOUT <?php  and ?>. Exactly as below:

  echo $phpAds_raw['120']['html'];

Quote · 29 Aug 2013

first, have you tried creating a bare bones php page with those entries? Keeping dolphin out of it so you know you even have local mode setup correctly...

Quote · 29 Aug 2013

I made file PHP, which contains code belo and it works correctly. There was 3 blocks at page. So code is right, but i don't know how to insert it to dolphin.

<?php

  //<!--/* OpenX Local Mode Tag v2.8.11 */-->

  define('MAX_PATH', '/var/www/opx');

  if (@include_once(MAX_PATH . '/www/delivery/alocal.php')) {

    if (!isset($phpAds_context)) {

      $phpAds_context = array();

    }

//468

    $phpAds_raw['468'] = view_local('', 15, 0, 0, '', '', '0', $phpAds_context, '');

    $phpAds_context[] = array('!=' => 'campaignid:'.$phpAds_raw['468']['campaignid']);

//$phpAds_context[] = array('!=' => 'bannerid:'.$phpAds_raw['4a']['bannerid'])

 

//RUN

$phpAds_raw['RUN'] = view_local('', 18, 0, 0, '', '', '0', $phpAds_context, '');

    $phpAds_context[] = array('!=' => 'campaignid:'.$phpAds_raw['RUN']['campaignid']);

 

//120

$phpAds_raw['120'] = view_local('', 1, 0, 0, '', '', '0', $phpAds_context, '');

    $phpAds_context[] = array('!=' => 'campaignid:'.$phpAds_raw['120']['campaignid']);

  }

  echo $phpAds_raw['468']['html'];

echo $phpAds_raw['120']['html'];

echo $phpAds_raw['RUN']['html'];

 ?>

Quote · 29 Aug 2013

my guess is that dolphin must be mangling or not processing the paths properly... there might be a better place to put:

  define('MAX_PATH', '/var/www/opx');

  if (@include_once(MAX_PATH . '/www/delivery/alocal.php')) {

    if (!isset($phpAds_context)) {

      $phpAds_context = array();

    }

 

that part of the local mode script...

Quote · 30 Aug 2013
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.