coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: silly_walk on February 14, 2006, 07:57:16 PM

Title: How can I include a file like anycontent on every page EXCEPT a certain album?
Post by: silly_walk on February 14, 2006, 07:57:16 PM
Hi,

I'd like to use one file to display my Adsense ads, but I'd also like to exclude 1 album. If I remove the
             if ($cat == 0)
from
            case 'anycontent':
                if ($cat == 0) {
                    include('anycontent.php');
                }
                flush();
                break;

I can make anycontent appear on any index.php page, but as soon as I navigate to a thumbnail.php page, I lose the content. Can someone tell me what code to include in which files to allow the file to NOT display in only a certain album?

Thanks in advance.
Title: Re: How can I include a file like anycontent on every page EXCEPT a certain albu
Post by: Joachim Müller on February 16, 2006, 09:39:55 AM
Instead of using anycontent.php, you should use the custom header or custom footer feature that was introduced in cpg1.4.x (see docs). Add a switch like if ($album != 'id_of_the_album_that_isn't_meant_to_show_ads') {
    print 'Your adsense code here';
}
in the custom header include file.
Title: Re: How can I include a file like anycontent on every page EXCEPT a certain albu
Post by: silly_walk on February 16, 2006, 11:16:46 PM
I created a new file named ad.php to use as a custom header, and used your exact code (substituting the album # for '2'). There is no other code in the file, but the displayed result only prints the code you gave me (above and below or on either side of the ad), while properly displaying the ad.

Unless I'm misunderstanding you...? You can see the result http://sillywalker.com/testcopp/index.php (http://sillywalker.com/testcopp/index.php)

Title: Re: How can I include a file like anycontent on every page EXCEPT a certain album?
Post by: Nibbler on February 16, 2006, 11:23:53 PM
Make sure you put the code inside php tags


<?php

code here

?>

Title: Re: How can I include a file like anycontent on every page EXCEPT a certain albu
Post by: silly_walk on February 17, 2006, 02:53:13 AM
OK, so I placed the following code in the ad.php file, and used the {CUSTOM_HEADER} to call it in the config:
<?php
if ($album != '2') {
    print 
'ad_code_here';
}
?>

This got rid of the code actually printing (thanks, Nibbler). But if I navigate to the album I want the ads to NOT appear on, they appear anyway.

What am I doing wrong?
Title: Re: How can I include a file like anycontent on every page EXCEPT a certain albu
Post by: silly_walk on February 20, 2006, 07:16:10 PM
Help?
Title: Re: How can I include a file like anycontent on every page EXCEPT a certain album?
Post by: Nibbler on February 20, 2006, 07:30:22 PM
Change $album to $_GET['album']
Title: Re: How can I include a file like anycontent on every page EXCEPT a certain albu
Post by: silly_walk on February 23, 2006, 02:43:46 AM
Quote from: Nibbler on February 20, 2006, 07:30:22 PM
Change $album to $_GET['album']
Worked perfectly, thanks loads! :)