Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1] 2   Go Down

Author Topic: Random logo with custom header file  (Read 32576 times)

0 Members and 1 Guest are viewing this topic.

Ludo

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 706
    • E+GiElle
Random logo with custom header file
« on: February 09, 2008, 03:04:10 pm »

Here's a little hack to display a random logo from a specific folder in your theme's directory (applies only to themes where it exists and contains images).
It's based on custom header file: if you already have set one, probably you won't be able to use this hack.
Basic HTML and CSS knowledge required.
Demo on my site http://vanrokken.altervista.org/
Any comment or suggestion appreciated.

OPEN
themes/your_theme/template.html

FIND
logo image "src" HTML attribute or "background"/"background-image" CSS property of the element containing the logo, e.g. in Classic theme:
Code: [Select]
<a href="index.php"><img src="themes/classic/images/site_logo.png" border="0" alt="" /></a><br />in Project VII:
Code: [Select]
<div style="background-image:url(themes/project_vii/images/top_panel_r1_c1.jpg);background-repeat:no-repeat">
If you can't find any, probably the "background"/"background-image" property of the element containing the logo is set in the element class/id declaration in themes/your_theme/style.css, like in Connections theme:
Code: [Select]
#header {
        background: #FFF url(themes/connections/images/top.jpg) no-repeat bottom;
  height: 183px;
margin: 0 auto;
width:760px;
padding:0;
border:#fc9 0px solid;
}


REPLACE
logo image "src" attribute or "background"/"background-image" url path with {CUSTOM_HEADER}, e.g.
Code: [Select]
<img src="{CUSTOM_HEADER}" border="0" alt="" />
Code: [Select]
<div style="background-image:url({CUSTOM_HEADER});background-repeat:no-repeat">If "background"/"background-image" url path is set in style.css, you will have to delete or comment that property in CSS file and add an inline style to the element containing the logo, e.g.
Code: [Select]
<div id="header" style="background: #FFF url({CUSTOM_HEADER}) no-repeat bottom;">

DELETE
any other occurrence of {CUSTOM_HEADER} in the file, including elements containing it

SAVE AND CLOSE

COPY AND PASTE THE FOLLOWING CODE IN A NEW FILE AND SAVE IT AS
include/custom_header.php
Code: [Select]
<?php
// Custom header file for Coppermine Picture Gallery 1.4.x
// Allows to show a random logo from a logos folder
// created in your theme's directory
// (c) 2008 Gian Luigi Rocca (Ludo)
// support: http://forum.coppermine-gallery.net/index.php?topic=50365.0

// Change $deflogo to match your default logo's name
$deflogo 'top.jpg';

// Set $use_session to true if you want the logo to change on every 
// session instead on every page visited.
// If you don't have 'session.auto_start' set to 1 in your PHP 
// settings, to enable sessions you will have to add a line
// 'session_start();' at the end of your include/config.inc.php
$use_session false;

$imgdir 'themes/'.$CONFIG['theme'].'/images/';
$logodir $imgdir."logos/";
$logo $imgdir.$deflogo
if (
$dir  = @opendir($logodir)) {        
    while (
false !== ($file = @readdir($dir))) {
        if (
is_file($logodir.$file)) {
            
$files[] = $file;
        }
    }
    if (isset(
$files)) {
        
$i rand(0count($files)-1);
        
$logo $logodir.$files[$i];      
    } 
}
if (!
$use_session) {
   echo 
$logo;
} else {
   if (!isset(
$_SESSION['logo'])) $_SESSION['logo'] = $logo;         
   echo 
$_SESSION['logo'];
}
?>

Notes:
1) Change $deflogo to match your default logo's name
2) By default, logo changes on every page visited. If you'd like it to change on every session (so that every visitor gets the same logo until he closes browser), set $use_session to true. If you don't have 'session.auto_start' set to 1 in your PHP configuration file (check it from Admin Tools > phpinfo), to enable sessions you'll have to add a line
Code: [Select]
session_start();
at the end of your include/config.inc.php (just before ?>)

CREATE
a subfolder named 'logos' in themes/your theme/images and fulfill it with your logos

ENTER
'include/custom_header.php' in 'Path to custom header include' field under Configuration > Theme settings

SAVE AND ENJOY!
« Last Edit: January 09, 2009, 12:33:45 am by Ludo »
Logged

Qayyom

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 52
    • www.PICSnCLIPS.net
Re: Random logo with custom header file
« Reply #1 on: June 17, 2008, 08:05:24 am »

Hi I like the nice Idea and want to use for my site.

But i have not enough knowledge to edit easily and implement.

I am using Oranje theme. please do the favor and edit the codes here, with necessary instructions

here is my template.html file

Code: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html dir="{LANG_DIR}">
<head>
<meta http-equiv="Content-Type" content="text/html; charset={CHARSET}" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Pragma" content="no-cache" />
<title>{TITLE}</title>
{META}
<link rel="stylesheet" href="themes/oranje/style.css" type="text/css" />
<script type="text/javascript" src="scripts.js"></script>
</head>
<body style="bodybody">
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0" style="background-image:url(themes/oranje/images/bg.gif);">
<tr>
<td width="760" valign="top" align="center">
{CUSTOM_HEADER}
</td>
</tr>
<tr><td height="1" align="center"><img src="themes/oranje/images/black_spacer.gif" width="758" height="1" border="0" alt="" /></td></tr>
<tr>
    <td width="760" valign="top" align="center"  style="padding-right:10px; background-repeat: no-repeat; background-position: center left; background-image:url(themes/oranje/images/logo.jpg);">
        <table cellpadding="0" cellspacing="3" border="0" width="100%"><tr>
<td align="right">
<h1><font color="#FFFFFF">{GAL_NAME}</font></h1>
<font color="#FFFFFF">{GAL_DESCRIPTION}</font><p>
<font color="#FFFFFF"><br />
</font>
</td></tr></table>
      </td>
  </tr>
<tr><td height="1" align="center"><img src="themes/oranje/images/black_spacer.gif" width="758" height="1" border="0" alt="" /></td></tr>

  <tr>
        <td width="760" valign="top" align="left">
            <table width="756" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
            <td valign="top" align="left" width="640">

{GALLERY}

  </td>
            <td valign="top" align="left" width="116" style="padding-top:15px;">
<div id="sidebar">

{SYS_MENU}<br/><br/> {SUB_MENU}<br/><br/>  {ADMIN_MENU}
<br /><br />{THEME_SELECT_LIST}<br /><br />
{LANGUAGE_SELECT_LIST}

</div>
</td>
              </tr>
            </table>
          <br />
    </td>
  </tr>
<tr><td height="1" align="center"><img src="themes/oranje/images/black_spacer.gif" width="758" height="1" border="0" alt="" /></td></tr>
  <tr>
    <td valign="bottom">
<div align="center">{LANGUAGE_SELECT_FLAGS}</div>
{CUSTOM_FOOTER}
{VANITY}
  </td>
  </tr>
<tr><td height="1" align="center"><img src="themes/oranje/images/black_spacer.gif" width="758" height="1" border="0" alt="" /></td></tr>
</table>
</body>
</html>

and here is [i think] only header related codes in style.css file, instead of complete file

Code: [Select]
#header {
padding: 0;
margin: 0 auto;
height: 200px;
width: 100%;
background-color: #73a0c5;
}

#headerimg {
margin: 0;
height: 200px;
width: 100%;
}

I'll be grateful for the help
Logged
Qayyom Ashraf .:|:. Karachi-PK
 *Image Removed*

Ludo

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 706
    • E+GiElle
Re: Random logo with custom header file
« Reply #2 on: June 17, 2008, 02:38:33 pm »

In template.html:

FIND AND DELETE:
Code: [Select]
<tr>
<td width="760" valign="top" align="center">
{CUSTOM_HEADER}
</td>
</tr>

FIND:
Code: [Select]
    <td width="760" valign="top" align="center"  style="padding-right:10px; background-repeat: no-repeat; background-position: center left; background-image:url(themes/oranje/images/logo.jpg);">
REPLACE WITH:
Code: [Select]
    <td width="760" valign="top" align="center"  style="padding-right:10px; background-repeat: no-repeat; background-position: center left; background-image:url({CUSTOM_HEADER});">
SAVE AND CLOSE

That's it! ;)
Logged

Qayyom

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 52
    • www.PICSnCLIPS.net
Re: Random logo with custom header file
« Reply #3 on: June 18, 2008, 05:54:01 am »

thanks for your help

Thanks again
Logged
Qayyom Ashraf .:|:. Karachi-PK
 *Image Removed*

Jittery Jim

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: Random logo with custom header file
« Reply #4 on: November 10, 2008, 06:41:50 pm »

Great mod, just what I was looking for. It's working with the Briarpatch theme, except for one problem. At the top of each page, right above the image, it lists the path and image name for which ever logo it is showing:

http://img.photobucket.com/albums/v158/jenloe_watches/z_pmwf/CoppermineError.jpg [Edit GauGau] Replaced hotlinked image with attachment as per Board rules / Forum policies: Add Attachments [/Edit]

It shows up whether logged in or not. I've checked all my edits and they match the instructions provided above.

Site url is http://watches.jitteryjim.com

Any suggestions or help would be appreciated.
« Last Edit: November 12, 2008, 12:11:45 am by Joachim Müller »
Logged

Ludo

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 706
    • E+GiElle
Re: Random logo with custom header file
« Reply #5 on: November 10, 2008, 06:57:51 pm »

It seems like you didn't delete (all the) old occurrences of {CUSTOM_HEADER} token in your template.html
Logged

Jittery Jim

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: Random logo with custom header file
« Reply #6 on: November 10, 2008, 09:31:24 pm »

It seems like you didn't delete (all the) old occurrences of {CUSTOM_HEADER} token in your template.html

I knew it had to be something simple. Thanks, that fixed the problem!
Logged

Deus

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 153
    • DJ-Daz
Re: Random logo with custom header file
« Reply #7 on: January 02, 2009, 11:06:54 am »

Many thanks Ludo, works brilliantly.
I use mac_ox_x theme and it looks poor, so I tried to use it in an anycontent.php file without success.
I'm wondering what I need to do to make it work this way.

Code: [Select]
<center>
<img src="{CUSTOM_HEADER}" border="0" alt="" /><center>
I've also tried:
Code: [Select]
<center>
<img src="/include/{CUSTOM_HEADER}" border="0" alt="" /><center>
without any luck.
I'm not sure whats going wrong, I've moved the logos folder to the root of coppermine and the root of themes.
Thanks for any help I can get.
Logged
https://daz-stuff.uk
DJ tutorials, E-Bikes, Movies and videogames.
(https://daz-stuff.uk/daz/signature.png)

Ludo

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 706
    • E+GiElle
Re: Random logo with custom header file
« Reply #8 on: January 05, 2009, 06:05:12 pm »

logos folder must be in themes/mac_ox_x/images

To get this mod working with mac_ox_x theme follow these steps:

OPEN
themes/mac_ox_x/template.html (the original version)

FIND AND DELETE
Code: [Select]
<div id="CUSTOM_HEADER">
  {CUSTOM_HEADER}
</div>

FIND
Code: [Select]
<div class="top_panel">
  <div class="top_panel_r">

REPLACE WITH
Code: [Select]
<div class="top_panel" style="background-image: url({CUSTOM_HEADER})">
  <div class="top_panel_r" style="background-image: url({CUSTOM_HEADER})">


OPEN
themes/mac_ox_x/style.css

FIND AND DELETE OR COMMENT OUT
Code: [Select]
background-image: url(images/top_panel_r1_c1b.gif);
FIND AND DELETE OR COMMENT OUT
Code: [Select]
background-image: url(images/top_panel_r1_c2.jpg);

SAVE AND CLOSE ALL FILES

(Let me know if it works, I didn' test it ;) )
Logged

Deus

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 153
    • DJ-Daz
Re: Random logo with custom header file
« Reply #9 on: January 05, 2009, 06:41:39 pm »

Thanks Ludo, I'll give it a go soon, and let you know.
Darron
Logged
https://daz-stuff.uk
DJ tutorials, E-Bikes, Movies and videogames.
(https://daz-stuff.uk/daz/signature.png)

Deus

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 153
    • DJ-Daz
Re: Random logo with custom header file
« Reply #10 on: January 05, 2009, 07:47:30 pm »

themes/mac_ox_x/style.css

FIND AND DELETE OR COMMENT OUT
Code:

background-image: url(images/top_panel_r1_c1b.gif);


FIND AND DELETE OR COMMENT OUT
Code:

background-image: url(images/top_panel_r1_c2.jpg);



SAVE AND CLOSE ALL FILES

From what you are asking me to remove, I can see you are trying to get this working with OX_X theme.
I am trying to get it working in an anycontent block.
Also, I cannot delete those lines from the CSS as they dont exist.
What I'm tring to do it get a random image to replace Motorstom Pacific rift logo from here... my gallery
at the top of the page.
Logged
https://daz-stuff.uk
DJ tutorials, E-Bikes, Movies and videogames.
(https://daz-stuff.uk/daz/signature.png)

Ludo

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 706
    • E+GiElle
Re: Random logo with custom header file
« Reply #11 on: January 06, 2009, 03:29:12 pm »

I am trying to get it working in an anycontent block.
This mod can't work in anycontent.php, because tokens get replaced in evaluating template file!

Quote
Also, I cannot delete those lines from the CSS as they dont exist.
Lines 145 and 152.
Logged

Deus

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 153
    • DJ-Daz
Re: Random logo with custom header file
« Reply #12 on: January 08, 2009, 07:32:36 pm »

I needed it to work in anycontent.
Thankyou for your time and patience Ludo, I shall find some html code that can work in there.
Logged
https://daz-stuff.uk
DJ tutorials, E-Bikes, Movies and videogames.
(https://daz-stuff.uk/daz/signature.png)

Ludo

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 706
    • E+GiElle
Re: Random logo with custom header file
« Reply #13 on: January 09, 2009, 12:15:00 am »

You can save my custom_header.php code above as your anycontent.php, adding this line
Code: [Select]
$logo = "<img src=\"$logo\" alt=\"logo\" />";
before
Code: [Select]
if (!$use_session) {
This will show a random image from the specified folder. Obviously you can add other code, or put the echoes wherever you want in the code itself.
If all images to show in anycontent.php have the same size, you'd better specify width and height attributes of <img> tag.
« Last Edit: January 09, 2009, 11:33:04 am by Ludo »
Logged

Deus

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 153
    • DJ-Daz
Re: Random logo with custom header file
« Reply #14 on: January 10, 2009, 01:17:43 am »

I'm loosing track of what edits are needed Ludo.
Any chance you could tell me whats needed for anycontent please.
Logged
https://daz-stuff.uk
DJ tutorials, E-Bikes, Movies and videogames.
(https://daz-stuff.uk/daz/signature.png)

Ludo

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 706
    • E+GiElle
Re: Random logo with custom header file
« Reply #15 on: January 10, 2009, 09:21:34 am »

Just save this code as your anycontent.php:
Code: [Select]
<?php
// Custom anycontent.php file for Coppermine Picture Gallery 1.4.x
// Allows to show a random image from a specified folder
// created in your theme's directory
// (c) 2009 Gian Luigi Rocca (Ludo)
// support: http://forum.coppermine-gallery.net/index.php?topic=50365.0

// Change $defany to match your default image name
$defany 'top.jpg';

// By default, images to show in anycontent.php are stored in themes/your_theme/images/anycontent
// If you have them stored elsewhere, change $imgdir and $anydir accordingly
$imgdir 'themes/'.$CONFIG['theme'].'/images/';
$anydir $imgdir."anycontent/";

$any $imgdir.$defany
if (
$dir  = @opendir($anydir)) {        
    while (
false !== ($file = @readdir($dir))) {
        if (
is_file($anydir.$file)) {
            
$files[] = $file;
        }
    }
    if (isset(
$files)) {
        
$i rand(0count($files)-1);
        
$any $anydir.$files[$i];      
    } 
}
$any "<img src=\"$any\" alt=\"image\" />";

// Your anycontent.php code
// By echoing $any you display a random image, e.g. 
// echo $any;

?>
Change $defany to your default image file name, and $anydir to the path where you have stored images to show, if different than default.
To display the random image anywhere you want in your anycontent.php code you just have to print $any variable.
« Last Edit: January 10, 2009, 03:51:35 pm by Ludo »
Logged

Deus

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 153
    • DJ-Daz
Re: Random logo with custom header file
« Reply #16 on: January 10, 2009, 11:25:02 am »

Thank you so much Ludo, it works brilliantly.
http://www.mess-hall.co.uk/gallery
It's the table just under friends.
I just need to get busy now with more logo's.


And now we have a random image in anycontent.php too.

Edit:
If I want to have a clickable link for each logo, taking you to the devolpers website, can I use a
$define or $link and logo=http://www.logo.com
$define or $link and logo=http://www.logo1.com
$define or $link and logo=http://www.logo2.com
$define or $link and logo=http://www.logo3.com

then output the link <a href='$link';

I'm not asking you to do this for me Ludo, just a pointer. I'm not sure about the define and output.

it's probably not the best place to ask, it's a coppermine forum after all and not a php forum.
« Last Edit: May 10, 2009, 02:51:47 am by Deus »
Logged
https://daz-stuff.uk
DJ tutorials, E-Bikes, Movies and videogames.
(https://daz-stuff.uk/daz/signature.png)

Ludo

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 706
    • E+GiElle
Re: Random logo with custom header file
« Reply #17 on: January 10, 2009, 03:45:11 pm »

I'm not sure I've understood exactly what you mean, but the only way to place a link for each random image without storing it in the database is to put the url in the name of each image file, e.g.
www.logo1.com_img1.jpg
logo2.altervista.org_img2.jpg
and then get it using explode("_", $file) while scanning $anydir
Logged

Deus

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 153
    • DJ-Daz
Re: Random logo with custom header file
« Reply #18 on: January 10, 2009, 04:12:14 pm »

forget I asked Ludo, I thought it might be a nice idea, but on reality, it's not necessary.
Some idea's seem good at the time, but this one is silly.
I thought it might be a good idea to place a link to a game developers site within each game logo, but if a user can't google it, why bother.

Edit:
At least no, as I said before, we have random logo header and random logo anycontent.


Many, Many thanks.
Darron
Logged
https://daz-stuff.uk
DJ tutorials, E-Bikes, Movies and videogames.
(https://daz-stuff.uk/daz/signature.png)

Deus

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 153
    • DJ-Daz
Re: Random logo with custom header file
« Reply #19 on: January 10, 2009, 07:18:34 pm »

I'm sorry to pester you further Ludo, but how can I get this code to follow the theme rules?
It's not displaying correctly, ie, there's no definition for tableb so it's not displaying a white background or the black borders around the table.
I've added starttable("100%", " "); so it looks like the rest of the page, but it shows an off white background and not a white one.
I searched and tried everything I can to fix it myself. I either get T_String errors or parse errors if I format using HTML.
So how do I either 1, Get a white background, or 2, get it formatted to tableb as all the other anycontent files are?
 ??? ??? ??? :'(



Code: [Select]
<?php
// Custom anycontent.php file for Coppermine Picture Gallery 1.4.x
// Allows to show a random image from a specified folder
// created in your theme's directory
// (c) 2009 Gian Luigi Rocca (Ludo)
// support: http://forum.coppermine-gallery.net/index.php?topic=50365.0

// Change $defany to match your default image name
$defany 'logo.png';
if (!
defined('IN_COPPERMINE')) die('Not in Coppermine...');
starttable("100%"" ");

// By default, images to show in anycontent.php are stored in themes/your_theme/images/anycontent
// If you have them stored elsewhere, change $imgdir and $anydir accordingly
$imgdir 'themes/'.$CONFIG['theme'].'/images/';
$anydir $imgdir."logos/";

$any $imgdir.$defany
if (
$dir  = @opendir($anydir)) {        
    while (
false !== ($file = @readdir($dir))) {
        if (
is_file($anydir.$file)) {
            
$files[] = $file;
        }
    }
    if (isset(
$files)) {
        
$i rand(0count($files)-1);
        
$any $anydir.$files[$i];      
    } 
}
$any "<center><img src=\"$any\" alt=\"Lots of Logo's\" /></center>";

// Your anycontent.php code
// By echoing $any you display a random image, e.g. 
echo $any;
endtable();
?>


Logged
https://daz-stuff.uk
DJ tutorials, E-Bikes, Movies and videogames.
(https://daz-stuff.uk/daz/signature.png)
Pages: [1] 2   Go Up
 

Page created in 0.027 seconds with 19 queries.