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]
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.
- 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(),
- find
function 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 out
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
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
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
sure this is possible, but I won't do customizations, as I already told you.
GauGau
I know. Infact I didn't ask for it. I just asked if it was possible to do it.
THank u!
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
merged threads.
GauGau
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.
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.
when uncommeting //return $phpAds_raw['html'];
, did you see the ouput "Banner here" on your page?
GauGau
Yes, I went all the way until this, and the "banner here" message is there: www.huecos.com/fotos
thank you.
shutiri.
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
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.
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
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.
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;
}
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.
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
ok... thank you.
Can I create a new topic with the title "phpadsnew/CPG integration" so if somebody knows or already had this trouble can answer me ?
shutiri.
GauGau
Ive read through many of the posts regarding phpads, and implementing the banner invokation code into coopermine, and as with many of the others Ive ran into the same problems.
Ive followed all the steps throughout this post regardig the modification of theme.php and creating '{BANNER}' => theme_custom_banner() in the $template_vars portion of this file.
Having said that, and reaching the same road blocks, here is a new piece of information to this puzzel:
Running debug upon reaching the roadblock "There was an error while processing a database query."
Ive come across the following:
------------------------
While executing query "SELECT COUNT(*) from BW_comments, BW_pictures WHERE approved = 'YES' AND BW_comments.pid = BW_pictures.pid " on 0
mySQL error: Table 'adclicks.bw_comments' doesn't exist
------------------------
'BW' is my prefix for Coopermine, and 'adclicks' is my prefix for my phpads database.
If looks as though calling the invocation code of phpads is placing its database name infront of the remaining calls in coopermine. And then the rest just goes to hell.
Thoughts?
yes: the mySQL connection to your banner software hasn't been established properly. I'm not sure if your banner script will work at all - you simply can't combine some sorts of scripts.
GauGau
Interesting. Use anycontent.php to accomplish this. Take a look at our website. The rotating amazon ads at the bottom. ;)
Quote from: DefenceTalk.com on June 07, 2004, 01:51:31 PM
Interesting. Use anycontent.php to accomplish this. Take a look at our website. The rotating amazon ads at the bottom. ;)
We are using that method of calling banners. I dont think you are grasping the issue at hand with PHPADS.
GAUGAU:
Is there a way in which to re-set the coppermine DB names, or DB prefixes. I think if i re-set this variable after I make my call to phpads, then everything would be back to normal in the coopermine world following the PHPADS call.
I don't understand fully - do you mean you want to end the established connection to the db at some point, or do you want to just rename the prefix once?
GauGau
in calling the banner.php code, thus initiating the communication link to PHPADS, it apparently sets the DB prefix or connection VAR to its own known variable.
-----------EXAMPLE---------------
While executing query "SELECT COUNT(*) from BW_comments, BW_pictures WHERE approved = 'YES' AND BW_comments.pid = BW_pictures.pid " on 0
mySQL error: Table 'adclicks.bw_comments' doesn't exist
-----------EXAMPLE---------------
coopermine fires, DB name/prefix = "BW_"
PHPADS fires, DB name/prefix is modified to: "adclicks.BW_"
apparently it overwrites this prefix variable used in DB connectivity.
After I make my call to PHPADS, can i re-initiate the coppermine DB prefix back to "BW_"?
So my code for banner.php would look something like:
Quote
<?php
// PHPADS BANNER CODE
if (@include('C:/PHPADS/phpadsnew.inc.php')) {
if (!isset($phpAds_context)) $phpAds_context = array();
$phpAds_raw = view_raw ('', 31, '_blank', '', '0', $phpAds_context);
$phpAds_context[] = array('!=' => 'bannerid:'.$phpAds_raw['bannerid']);
}
// Assign the $phpAds_raw['html'] variable to your template
echo $phpAds_raw['html'];
$banner = "<center>$phpAds_raw['html']</center>";
// PHPADS BANNER CODE
//RE-INITIATE THE DB PREFIX HERE
?>
So that once PHPADS was done, and coopermine continues through its processes remaining, it has the correct DB prefix.
I'm not sure what vars are being reset by phpAds, try re-setting the db prefix after the phpAds code like this:$CONFIG['TABLE_PREFIX'] = "yourCopperminePrefix_";
GauGau
Negative Ghost-Rider, same thing.
I added to the last line of my Banner.php file the re-setting of the DB prefix var.
DEBUG INFOThere was an error while processing a database query.
Quote
While executing query "SELECT COUNT(*) from BW_comments, BW_pictures WHERE approved = 'YES' AND BW_comments.pid = BW_pictures.pid " on 0
mySQL error: Table 'adclicks.bw_comments' doesn't exist
File: C:\The\Path\To\MySite\include\functions.inc.php - Line: 101
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Line 101 of functions.inc.php contains the following (LN 87- LN 103)
Quote
// Error message if a query failed
function db_error($the_error)
{
global $CONFIG;
if (!$CONFIG['debug_mode']) {
cpg_die(CRITICAL_ERROR, 'There was an error while processing a database query', __FILE__, __LINE__);
} else {
$the_error .= "\n\nmySQL error: ".mysql_error()."\n";
$out = "<br />There was an error while processing a database query.<br /><br/>
<form name='mysql'><textarea rows=\"8\" cols=\"60\">".htmlspecialchars($the_error)."</textarea></form>";
cpg_die(CRITICAL_ERROR, $out, __FILE__, __LINE__);
}
}
Line 1098 of functions.inc.php contains the following (LN1091 - LN 1102)
Quote
if((($mode == "normal") || ($mode == 'fullsize')) && ($CONFIG['thumb_method']=='im')){
// return the url to the wm script
return "wm.php?pid=".$pic_row["pid"]."&mode=".$mode;
}else{
// it's a thumb, don't bother wm'ing
if (is_null($pic_row['pid']) || !isset($CONFIG['url_mode']) || $CONFIG['url_mode']!='hide')
return $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);
return 'get_file.php?pid='.$pic_row['pid'].'&size='.$mode;
}
and, at the very bottom the SQL Query Debug Info:
Quote
USER:
Array
(
[ID] => f906caa6dd5e01a219b7fb162eca3287
[am] => 1
[liv] => Array
(
- => 108
[1] => 263
[2] => 78
[3] => 202
)
)
GET :
Array
(
)
POST :
Array
(
)
Thoughts?
GauGau:
What's the PRO/CON of making a function in theme.php for the phpAdsNew code (or any other code for that matter) and then inserting the {BANNER} tag into template.html
vs.
insertint the phpAdsNew code directly into template.html ???
Only html can go into the template. PHP goes into the theme.php
I have a question. I use this solution but i have 1 problem. When i enetered a this codes script show at the bottom of page. Not where {BLABLA} is but at first, before logo. ??? What i must do ?
The code you have added probably outputs using echo or similar. It should return all its output as the result of the function in which it resides. If you can't do this easily you can use output buffering to capture the output.
I have solved this problem!
Add the phpAdsNew "Local Mode" php invocation code to the "../include/functions.inc.php" file. Add it "AS IS" how the phpAdsNew code generator gives it to you. Make sure to click on "Store the banner inside a variable so it can be used in a template" before generating the phpAdsNew code. And add it to functions.inc.php at the very top, before
// Decode the user profile contained in a cookie
function user_get_profile()
Thats it for the functions.inc.php file.
Edit themes.php, find:
global $CONFIG, $THEME_DIR;
replace it with:
global $CONFIG, $THEME_DIR, $phpAds_raw;
and find:
'{ADMIN_MENU}' => theme_admin_mode_menu()
add after:
'{BANNER}' => $phpAds_raw['html']
and make sure to add a comma (" , ") at the end of '{ADMIN_MENU}' => theme_admin_mode_menu()
to make it look like this '{ADMIN_MENU}' => theme_admin_mode_menu(),
since you are adding to the array.
That's it..
Enjoy!
Thanks ;)
I should probably also mention 2 things that might be obvious to some, but not others:
1) Remember to put the {BANNER} where ever you want the banner to appear in template.html
2) Remember to take out the first and last lines of the invocation code: "<$php" and "?>", when you put it in functions.inc.php
That's it!