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]   Go Down

Author Topic: different header image for each category?  (Read 7572 times)

0 Members and 1 Guest are viewing this topic.

wuschel_lux

  • Translator
  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 93
    • volleyball.lu - photo gallery & shop
different header image for each category?
« on: May 21, 2007, 11:06:47 am »

Hi,

I searched the forum to fin a hint to realize my project but I didn't realy found something.

I am working now on my project www.volleyball.lu. I have 5 different categories in the gallery. Now I want to have for each category a different header image. Normally this will not be a too great problem for me to code it in PHP, but in this case the template.html ist a HTML file.

Can someone give me a hint how to "include" a PHP script in the template file?

Tanks in advance
« Last Edit: May 23, 2007, 07:44:51 am by GauGau »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: different header image for each category?
« Reply #1 on: May 21, 2007, 03:10:31 pm »

That's what the custom_header feature is meant to be used for.
Logged

wuschel_lux

  • Translator
  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 93
    • volleyball.lu - photo gallery & shop
Re: different header image for each category?
« Reply #2 on: May 21, 2007, 03:40:08 pm »

Thanks GauGau for the hint an the perfect support on this site,

I will try to implement this this evening.

Regards
Logged

wuschel_lux

  • Translator
  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 93
    • volleyball.lu - photo gallery & shop
Re: different header image for each category?
« Reply #3 on: May 21, 2007, 04:52:37 pm »

so I tested the {Custom Header} and it works nearly fine.
- I got my header image
- got the $cat ID
- but I cant use the {LOGIN_FORM} in my header.php

What must I change to the code that it will be accepted?

Can somebody help me.

Thanks
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: different header image for each category?
« Reply #4 on: May 21, 2007, 05:59:50 pm »

The placeholder tokens in curly brackets get replaced when the template is being run. You can't use those placeholders outside of template.html.

For details, post details (link to your gallery, your code changes (attach your zipped theme and your custom include).
Logged

wuschel_lux

  • Translator
  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 93
    • volleyball.lu - photo gallery & shop
Re: different header image for each category?
« Reply #5 on: May 22, 2007, 08:15:39 am »

In this case its not so easy i thought. Here are more detailed infos:
- URL www.volleyball.lu/fotogallery
- Coppermine Photo Gallery 1.4.10 modpack
- Theme Oranje (modified a bit ...)

NOTE: The header.php is not the final version, was just quick and dirty to test. I will have to make DB querys to get from pic, the album id and category id.

I attached the files in the Oranje.zip with all theme files.

I hope this will help.

Thanks
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: different header image for each category?
« Reply #6 on: May 22, 2007, 08:22:31 am »

OK, here's the content of your header include:
Code: [Select]
<?php
        $cat 
$_GET["cat"];
        
//echo 'category = '.$cat;

        
switch ($cat) {
        case 
2:
                
$headIMG "logo_indoor.png";
                    
//echo "indoor";
                    
break;
        case 
3:
                
$headIMG "logo.png";
                    
//echo "beach";
                    
break;
        case 
4:
                
$headIMG "logo.png";
                    
//echo "archiv";
                    
break;
        case 
8:
                
$headIMG "logo.png";
                    
//echo "fun";
                    
break;
        case 
9:
                
$headIMG "logo.png";
                    
//echo "events";
                    
break;
        default:
                
$headIMG "logo.png";
                    
//echo "standard";
}
?>


         <tr>
          <td width="760" height="120" valign="top" align="center"  style="padding-right:10px; background-repeat: no-repeat; background-position: center left; background-image:url(themes/oranje/images/<?php echo $headIMG?>);">
        <table cellpadding="0" cellspacing="3" border="0" width="100%"><tr>
                        <td align="right">
                        <!-- <h1> {GAL_NAME}</h1>{GAL_DESCRIPTION} --> <br /><br /><br /><br /><br />
                        <font color="#ffffff">{LOGIN_FORM}</font><span style="font-size: 8px;"><br /></span>
                </td></tr></table>
      </td>
          </tr>
Why do you want to move stuff from template.html into it. Move
Code: [Select]
         <tr>
          <td width="760" height="120" valign="top" align="center"  style="padding-right:10px; background-repeat: no-repeat; background-position: center left; background-image:url(themes/oranje/images/<?php echo $headIMG?>);">
        <table cellpadding="0" cellspacing="3" border="0" width="100%"><tr>
                        <td align="right">
                        <!-- <h1> {GAL_NAME}</h1>{GAL_DESCRIPTION} --> <br /><br /><br /><br /><br />
                        <font color="#ffffff">{LOGIN_FORM}</font><span style="font-size: 8px;"><br /></span>
                </td></tr></table>
      </td>
          </tr>
back into themes/yourtheme/template.html, leaving header.php with only
Code: [Select]
<?php
        $cat 
$_GET["cat"];
        
//echo 'category = '.$cat;

        
switch ($cat) {
        case 
2:
                
$headIMG "logo_indoor.png";
                    
//echo "indoor";
                    
break;
        case 
3:
                
$headIMG "logo.png";
                    
//echo "beach";
                    
break;
        case 
4:
                
$headIMG "logo.png";
                    
//echo "archiv";
                    
break;
        case 
8:
                
$headIMG "logo.png";
                    
//echo "fun";
                    
break;
        case 
9:
                
$headIMG "logo.png";
                    
//echo "events";
                    
break;
        default:
                
$headIMG "logo.png";
                    
//echo "standard";
}
?>
in it.
Logged

wuschel_lux

  • Translator
  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 93
    • volleyball.lu - photo gallery & shop
Re: different header image for each category?
« Reply #7 on: May 22, 2007, 08:37:45 am »

thanks for your reply

but I dont understand how I can use <?php echo $headIMG; ?> in a .html file as you mentioned to not copy the table structure to the header.php file.

Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: different header image for each category?
« Reply #8 on: May 22, 2007, 08:43:02 am »

Ah OK, sorry for not looking more carefully.

header.php:
Code: [Select]
<tr>
          <td width="760" height="120" valign="top" align="center"  style="padding-right:10px; background-repeat: no-repeat; background-position: center left; background-image:url(themes/oranje/images/
<?php
        $cat 
$_GET["cat"];
        
//echo 'category = '.$cat;

        
switch ($cat) {
        case 
2:
                
$headIMG "logo_indoor.png";
                    
//echo "indoor";
                    
break;
        case 
3:
                
$headIMG "logo.png";
                    
//echo "beach";
                    
break;
        case 
4:
                
$headIMG "logo.png";
                    
//echo "archiv";
                    
break;
        case 
8:
                
$headIMG "logo.png";
                    
//echo "fun";
                    
break;
        case 
9:
                
$headIMG "logo.png";
                    
//echo "events";
                    
break;
        default:
                
$headIMG "logo.png";
                    
//echo "standard";
}

echo 
$headIMG;
?>

Back into template.html:
Code: [Select]
        <table cellpadding="0" cellspacing="3" border="0" width="100%"><tr>
                        <td align="right">
                        <!-- <h1> {GAL_NAME}</h1>{GAL_DESCRIPTION} --> <br /><br /><br /><br /><br />
                        <font color="#ffffff">{LOGIN_FORM}</font><span style="font-size: 8px;"><br /></span>
                </td></tr></table>
      </td>
          </tr>
Logged

wuschel_lux

  • Translator
  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 93
    • volleyball.lu - photo gallery & shop
Re: different header image for each category?
« Reply #9 on: May 22, 2007, 11:29:54 am »

thanks for your hint with splitting the code, now it works fine, I just have to code the category DB querry's.

When I finishe I will post the final code.

thanks for the great support
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: different header image for each category?
« Reply #10 on: May 22, 2007, 12:52:57 pm »

OK, great.
Another side-note: coppermine already populates the variable named $cat. So either use the one populated by coppermine or choose another name for your custom variable.
Logged

wuschel_lux

  • Translator
  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 93
    • volleyball.lu - photo gallery & shop
Re: different header image for each category?
« Reply #11 on: May 22, 2007, 12:57:14 pm »

OK, great.
Another side-note: coppermine already populates the variable named $cat. So either use the one populated by coppermine or choose another name for your custom variable.
I did it already, named it $catID
Logged

wuschel_lux

  • Translator
  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 93
    • volleyball.lu - photo gallery & shop
Re: different header image for each category?
« Reply #12 on: May 22, 2007, 01:29:00 pm »

I coded now the SQL querry, the header per category works fine  :) but I got an other big problem, when activating header.php  ???

When I click on the e.g. most viewed menu point I will get following error message:
Unknown column 'topn' in 'where clause'

What did I wrong? If I comment the SQL querry, it works again without error...

Can somebody help me. Thanks

Here my code:
Code: [Select]
<?php
        $mycatID   
$_GET["cat"];
$myalbumID $_GET["album"];
        
//echo 'category = '.$mycatID.'; album = '.$myalbumID;

if($myalbumID >= "0")
{
$sqlID 'SELECT `category` FROM `cpg1410_albums` WHERE `aid` = '.$myalbumID.' ';
$resultID mysql_query($sqlID) OR die(mysql_error());
while($rowID mysql_fetch_assoc($resultID)) {
$mycatID $rowID['category'];
        
//echo '; calculated category = '.$rowID['category'];
    
}

else
{$mycatID $mycatID;}

        switch (
$mycatID) {
        case 
2:
                
$headIMG "logo_indoor.png";
                    break;
        case 
3:
                
$headIMG "logo.png";
                    break;
        case 
4:
                
$headIMG "logo.png";
                    break;
        case 
8:
                
$headIMG "logo.png";
                    break;
        case 
9:
                
$headIMG "logo.png";
                    break;
        default:
                
$headIMG "logo.png";
}

?>

<tr>
          <td width="760" height="120" valign="top" align="center"  style="padding-right:10px; background-repeat: no-repeat; background-position: center left; background-image:url(themes/oranje/images/<?php echo $headIMG?>);">

Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: different header image for each category?
« Reply #13 on: May 22, 2007, 01:52:42 pm »

The variable "$album" is not only being populated with actual album IDs (i.e. numbers), but with the short names for meta albums as well. Subsequently, if you visit a meta album like best rated or most viewed, the query will fail. Add a check after
Code: [Select]
$myalbumID = $_GET["album"];that checks if $myalbumID is an integer. If it isn't, return the default header image without running the query. You have to be careful with your script: the $_GET array is being populated by the end user. If you use it, you'll have to sanitize the data before using them.

I'm not sure though why you need to run a query of your own - why don't you used the existing vars and functions?

Anyway, this is going beyond regular Coppermine support...
Logged

wuschel_lux

  • Translator
  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 93
    • volleyball.lu - photo gallery & shop
Re: different header image for each category?
« Reply #14 on: May 22, 2007, 02:21:39 pm »

I'm not sure though why you need to run a query of your own - why don't you used the existing vars and functions?
I am not sure that I must use a query, but for my understanding I found no other way to do it.

To get the category from the main page, I used the variable $cat.
But after if I am inside of an album I dont even have this variable filled. So I made the query with the album ID to find again the category ID.
How can I use the existing vars and functions?

I will try to rewrite the code with your tips ...

Thanks
Logged

wuschel_lux

  • Translator
  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 93
    • volleyball.lu - photo gallery & shop
Re: different header image for each category?
« Reply #15 on: May 22, 2007, 02:34:46 pm »

Thanks a lot GauGau.
After applying your tips the script seems to work perfekt. If it is the best way to do? I dont know, but it works and the result is what I want.
If sombody has a better solution, pleas share it with us.

So here again the code:
Code: [Select]
<?php
        $mycatID   
$_GET["cat"];
$myalbumID $_GET["album"];

//echo 'category = '.$mycatID; // OUTPUT VAR TEST

if (ereg("^[0-9]+[.]?[0-9]*$"$myalbumID$p)) {
$checkINT 1// is INT
} else {
$checkINT 0// is not INT
}


        if(
$checkINT == "1" && $myalbumID >= "0")
{
$sqlID 'SELECT `category` FROM `cpg1410_albums` WHERE `aid` = '.$myalbumID.' ';
$resultID mysql_query($sqlID) OR die(mysql_error());
while($rowID mysql_fetch_assoc($resultID)) {
$mycatID $rowID['category'];
    
}

else
{$mycatID $mycatID;}

        switch (
$mycatID) {
        case 
2:
                
$headIMG "logo_indoor.png";
                    break;
        case 
3:
                
$headIMG "logo.png";
                    break;
        case 
4:
                
$headIMG "logo.png";
                    break;
        case 
8:
                
$headIMG "logo.png";
                    break;
        case 
9:
                
$headIMG "logo.png";
                    break;
        default:
                
$headIMG "logo.png";
}
//echo '; album = '.$myalbumID.'; calculated category = '.$mycatID.'; is INT? = '.$checkINT; // OUTPUT VAR TEST
?>

<tr>
          <td width="760" height="120" valign="top" align="center"  style="padding-right:10px; background-repeat: no-repeat; background-position: center left; background-image:url(themes/oranje/images/<?php echo $headIMG?>);">
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: different header image for each category?
« Reply #16 on: May 23, 2007, 07:44:19 am »

Marking thread as "solved".
Logged
Pages: [1]   Go Up
 

Page created in 0.043 seconds with 20 queries.