how to add custom php script - DOESN'T WORK :( how to add custom php script - DOESN'T WORK :(
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

how to add custom php script - DOESN'T WORK :(

Started by gabIT, April 19, 2004, 09:04:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gabIT

Hello!

I use phpAdsNew and I need to display the banner in coppermine.

this is the invocation code from phpAdsNew.

<?php
    if (@include(getenv('DOCUMENT_ROOT').'/AdsNew/phpadsnew.inc.php')) {
        if (!isset($phpAds_context)) $phpAds_context = array();
        $phpAds_raw = view_raw ('zone:223', 0, '_blank', '', '0', $phpAds_context);
        $phpAds_context[] = array('!=' => 'bannerid:'.$phpAds_raw['bannerid']);
    }
   
    // Assign the $phpAds_raw['html'] variable to your template
    // echo $phpAds_raw['html'];
?>

I don't know if I have to include a {BANNER} in the template.html or something else in the theme.php

For me it doesn't make difference. I just need the banener shown in my page! :-)

Ciao!
Grazie!
Gabriele

[edit GauGau]
thread subject changed
[/edit]

Casper

Gabriele,

please give this topic a heading which readers will know what they are going to find in the topic.  A '?' or similar is not enough.
It has been a long time now since I did my little bit here, and have done no coding or any other such stuff since. I'm back to being a noob here

Joachim Müller

#2
  • edit template.html
  • add {BANNER}wherever you like.
  • edit theme.php
  • find        '{ADMIN_MENU}' => theme_admin_mode_menu(),and add after it'{BANNER}' => theme_custom_banner(),
  • findfunction theme_display_cat_list($breadcrumb, &$cat_data, $statistics)and add before itfunction theme_custom_banner()
    {
    if (@include(getenv('DOCUMENT_ROOT').'/AdsNew/phpadsnew.inc.php')) {
    if (!isset($phpAds_context)) $phpAds_context = array();
    $phpAds_raw = view_raw ('zone:223', 0, '_blank', '', '0', $phpAds_context);
    $phpAds_context[] = array('!=' => 'bannerid:'.$phpAds_raw['bannerid']);
    }

    // Assign the $phpAds_raw['html'] variable to your template
    // echo $phpAds_raw['html'];
    //return $phpAds_raw['html'];
    return 'Banner here';
    }

__________________________________________________________

Check if this works as expected and shows "Banner here" where it's expected to be. If yes, modify the last lines and uncomment return $phpAds_raw['html']; - comment outreturn 'Banner here';instead (make this a two-step process to check first if the insertion itself works and then if your banner rotation does). Report back if this worked for you.

GauGau

gabIT

problem....

this line
if (@include(getenv('DOCUMENT_ROOT').'/AdsNew/phpadsnew.inc.php')) {
causes a critical error in the displaying of the albums
"There was an error while processing a database query"
but it shows the banner.

if I use this
if (@include(getenv('DOCUMENT_ROOT').'http://domain.com/AdsNew/phpadsnew.inc.php')) {

the page is ok but no banner

gabIT

I am trying to find a solution to have targeted ads...

Do you think it's possible to have a function that checks the category number (either from the database or from the URL) and choose the right "function theme_custom_banner()"?

For istance...
when the album category is 3, then "function theme_custom_banner3()"
where the zone number 'zone:3'

(praferably, the functions are in a file outside theme.php)

THank you very much!
Gabriele

Joachim Müller

sure this is possible, but I won't do customizations, as I already told you.

GauGau

gabIT

I know. Infact I didn't ask for it. I just asked if it was possible to do it.

THank u!

gabIT

I use phpAdsNew to manage my ads, campaigns, ... and coppermine for my site.

Coppemrmine uses template.html and gaugau told me how to integrate the phpAdsNew invocation codes into coppermine template page.
(read above)

It works but still, not targeted ads.
 

----- THE NEED -----

I have a variable called {BANNER}

the value of this variable is defined by a function that checks which category you are browsing in for which it takes the piece of code with the specific value (ZONE) in it.

So if I have 10 categories I'll have 10 of the following ZONE CODE (XX = unique zone for unique cat.):

if (@include(getenv('DOCUMENT_ROOT').'/AdsNew/phpadsnew.inc.php')) {
if (!isset($phpAds_context)) $phpAds_context = array();
$phpAds_raw = view_raw ('zone:XX', 0, '_blank', '', '0',
$phpAds_context);
$phpAds_context[] = array('!=' => 'bannerid:'.$phpAds_raw['bannerid']);
}


Then there will be the function "theme_custom_banner()" that will take the right zone code (above) and give it on screen with something like this:

function theme_custom_banner()
{
if category ID = number XX
then take the ZONE CODE XX
return 'Banner for category XX';
}

So, in this way I will need one external file (external from theme.php) where I'll have all my ZONE CODES in it

I don't know if it's a big work but even if it is I am willing to pay!

Thanks!
Gabriele

Joachim Müller

merged threads.

GauGau

shutiri

I don't understand the last instructions:

QuoteIf yes, modify the last lines and uncomment
Code:
return $phpAds_raw['html'];
- comment out
Code:
return 'Banner here';
instead (make this a two-step process to check first if the insertion itself works and then if your banner rotation does). Report back if this worked for you.


There are 3 commented lines at the end.  I suppose I should uncomment the last 2.
Where does the phpadsnew code goes ?
Guessing:


// Assign the $phpAds_raw['html'] variable to your template
echo $phpAds_raw['html'];
return $phpAds_raw['html'];
return '<?php
    
if (@include(getenv('DOCUMENT_ROOT').'/phpadsnew/phpadsnew.inc.php')) {
        if (!isset(
$phpAds_context)) $phpAds_context = array();
        
$phpAds_raw view_raw ('zone:7'0'_blank''''0'$phpAds_context);
        echo 
$phpAds_raw['html'];
    }
?>

';
}


maybe without the <?php and ?>

thank you
shutiri.

shutiri

Ok, none of them worked (with or without <?php ?>)  I got errors.

then I tried:

// Assign the $phpAds_raw['html'] variable to your template
echo $phpAds_raw['html'];
return $phpAds_raw['html'];
//return 'Banner here';
   if (@include(getenv('DOCUMENT_ROOT').'/phpadsnew/phpadsnew.inc.php')) {
       if (!isset($phpAds_context)) $phpAds_context = array();
       $phpAds_raw = view_raw ('zone:7', 0, '_blank', '', '0', $phpAds_context);
       echo $phpAds_raw['html'];
   }


}


then I tried with complete URL : 'http://www.huecos.com/phpadsnew/phpadsnew.inc.php'; and didn't worked either.  I don't get any error, just that the banner doesn't shows up.

thank you
shutiri.


Joachim Müller

when uncommeting //return $phpAds_raw['html'];, did you see the ouput "Banner here" on your page?

GauGau

shutiri

Yes,  I went all the way until this, and the "banner here" message is there:  www.huecos.com/fotos

thank you.
shutiri.

Joachim Müller

that's the "proof of concept" then - you are able to output things with your theme. If it doesn't work as expected from now on, you'll have to modify your script you're actually including.

GauGau

shutiri

Yes, I understand that's the "proof of concept".   I wrote two posts ago some of  the things I tried to actually include the real code I have for the banner (I tried all combinations that came to my head since,  but don't get it working.  Can you please tell me where should I put the banner code ?  That's the last thing I need to get everything working  ;).

Thank you for your patience.
shutiri.

Joachim Müller

this would mean I'd actually have to look into the script you're trying to include. As I don't know phpAdsNew I'm reluctant to do so (same thing applies as I have already posted on this thread before, replying to gabIT: I won't do customizations for you).
Coppermine it set up to handle other scripts now, but if you can't get this other script working I can't help you.
Create a fresh file called test.php with this content<?php
    
if (@include(getenv('DOCUMENT_ROOT').'/phpadsnew/phpadsnew.inc.php')) {
        if (!isset(
$phpAds_context)) $phpAds_context = array();
        
$phpAds_raw view_raw ('zone:7'0'_blank''''0'$phpAds_context);
        echo 
$phpAds_raw['html'];
    }
?>
Check if it works (run it in your browser). If it doesn't work as expected, you've come to the wrong place...

GauGau

shutiri

yes, it works... it's the same code I had from phpadsnew code generator.  The banners are set up and working correctly.  My question is how do I "paste" it to the theme.php ?

I suppose I have to put it in one of this lines but I don't really know.

echo $phpAds_raw['html'];
return $phpAds_raw['html'];
//return 'Banner here';


Sorry if my question seems too stupid, but I really don't know how to refer to a file (test.php in this case) from the theme.php

thank you,
shutiri.



Joachim Müller

function theme_custom_banner()
{
    if (@include(getenv('DOCUMENT_ROOT').'/phpadsnew/phpadsnew.inc.php')) {
        if (!isset($phpAds_context)) $phpAds_context = array();
        $phpAds_raw = view_raw ('zone:7', 0, '_blank', '', '0', $phpAds_context);
        $return = $phpAds_raw['html'];
    }

return $return;
}

shutiri

Ok.  I'm getting closer.  Now I'm having the same problem than gabIT:

Quotethis line

if (@include(getenv('DOCUMENT_ROOT').'/AdsNew/phpadsnew.inc.php')) {
causes a critical error in the displaying of the albums
"There was an error while processing a database query"
but it shows the banner.

if I use this

if (@include(getenv('DOCUMENT_ROOT').'http://domain.com/AdsNew/phpadsnew.inc.php')) {

the page is ok but no banner

How do I solve that ?

thank you.
shutiri.

Joachim Müller

I don't know, because I'm not going to look into phpadsnew, since it's a third-party app! Get help on the support board of phpadsnew, not here. There are scripts that just can't be included though...

GauGau