Advanced search  

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

Pages: [1] 2   Go Down

Author Topic: how to add custom php script - DOESN'T WORK :(  (Read 23819 times)

0 Members and 2 Guests are viewing this topic.

gabIT

  • Coppermine newbie
  • Offline Offline
  • Posts: 16
    • http://www.gc-d.com
how to add custom php script - DOESN'T WORK :(
« on: April 19, 2004, 09:04:13 pm »

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]
Logged

Casper

  • VIP
  • Coppermine addict
  • ***
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 5231
how to add custom php script - DOESN'T WORK :(
« Reply #1 on: April 19, 2004, 09:47:52 pm »

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.
Logged
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

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
how to add custom php script - DOESN'T WORK :(
« Reply #2 on: April 20, 2004, 09:00:28 am »

  • edit template.html
  • add
    Code: [Select]
    {BANNER}wherever you like.
  • edit theme.php
  • find
    Code: [Select]
           '{ADMIN_MENU}' => theme_admin_mode_menu(),and add after it
    Code: [Select]
    '{BANNER}' => theme_custom_banner(),
  • find
    Code: [Select]
    function theme_display_cat_list($breadcrumb, &$cat_data, $statistics)and add before it
    Code: [Select]
    function 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
Code: [Select]
return $phpAds_raw['html']; - comment out
Code: [Select]
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.

GauGau
« Last Edit: May 02, 2004, 11:31:32 am by GauGau »
Logged

gabIT

  • Coppermine newbie
  • Offline Offline
  • Posts: 16
    • http://www.gc-d.com
WORKS <EDITED>
« Reply #3 on: April 20, 2004, 12:22:59 pm »

problem....

this line
Code: [Select]
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
Code: [Select]
if (@include(getenv('DOCUMENT_ROOT').'http://domain.com/AdsNew/phpadsnew.inc.php')) {

the page is ok but no banner
Logged

gabIT

  • Coppermine newbie
  • Offline Offline
  • Posts: 16
    • http://www.gc-d.com
how to add custom php script - DOESN'T WORK :(
« Reply #4 on: April 20, 2004, 01:32:43 pm »

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
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
how to add custom php script - DOESN'T WORK :(
« Reply #5 on: April 20, 2004, 11:04:47 pm »

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

GauGau
Logged

gabIT

  • Coppermine newbie
  • Offline Offline
  • Posts: 16
    • http://www.gc-d.com
how to add custom php script - DOESN'T WORK :(
« Reply #6 on: April 20, 2004, 11:19:48 pm »

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

THank u!
Logged

gabIT

  • Coppermine newbie
  • Offline Offline
  • Posts: 16
    • http://www.gc-d.com
targeted ads in cpg via phpAdsNew
« Reply #7 on: April 20, 2004, 11:41:03 pm »

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.):

Code: [Select]
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
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
[Moderation]
« Reply #8 on: April 20, 2004, 11:44:37 pm »

merged threads.

GauGau
Logged

shutiri

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 66
Re: how to add custom php script - DOESN'T WORK :(
« Reply #9 on: May 07, 2004, 01:13:51 pm »

I don't understand the last instructions:

Quote
If 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:


Code: [Select]
// 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.
Logged

shutiri

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 66
Re: how to add custom php script - DOESN'T WORK :(
« Reply #10 on: May 07, 2004, 01:28:42 pm »

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

then I tried:
Code: [Select]
// 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.

Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: how to add custom php script - DOESN'T WORK :(
« Reply #11 on: May 07, 2004, 03:11:09 pm »

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

GauGau
Logged

shutiri

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 66
Re: how to add custom php script - DOESN'T WORK :(
« Reply #12 on: May 07, 2004, 09:24:19 pm »

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

thank you.
shutiri.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: how to add custom php script - DOESN'T WORK :(
« Reply #13 on: May 08, 2004, 07:55:32 am »

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
Logged

shutiri

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 66
Re: how to add custom php script - DOESN'T WORK :(
« Reply #14 on: May 08, 2004, 08:48:17 am »

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.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: how to add custom php script - DOESN'T WORK :(
« Reply #15 on: May 08, 2004, 11:32:59 am »

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
Code: [Select]
<?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
Logged

shutiri

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 66
Re: how to add custom php script - DOESN'T WORK :(
« Reply #16 on: May 08, 2004, 12:46:50 pm »

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.

Code: [Select]
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.


Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: how to add custom php script - DOESN'T WORK :(
« Reply #17 on: May 08, 2004, 05:29:48 pm »

Code: [Select]
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;
}
Logged

shutiri

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 66
Re: how to add custom php script - DOESN'T WORK :(
« Reply #18 on: May 08, 2004, 10:00:57 pm »

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

Quote
this line

Code: [Select]
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

Code: [Select]
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.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: how to add custom php script - DOESN'T WORK :(
« Reply #19 on: May 09, 2004, 08:29:06 am »

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
Logged
Pages: [1] 2   Go Up
 

Page created in 0.025 seconds with 18 queries.