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

Author Topic: Add php-content to template.html via {CUSTOM_HEADER}?  (Read 5753 times)

0 Members and 1 Guest are viewing this topic.

KidSnare

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Add php-content to template.html via {CUSTOM_HEADER}?
« on: February 13, 2007, 12:46:22 am »

Hi,

I wanted to add some php-content to my template.html using the following "trick":

I have a file called "dates.php" and the template.html, where I added my header into the code. In one particular <tr> of the header I wanted to include the dates.php-file.
So I thought this could work: In the Control Panel I declared the URL www.mysite.com/dates.php as a Custom Header and added the link {CUSTOM_HEADER} to the <tr> in the template.html.

So my intention was that the dates.php is shown instead of {CUSTOM_HEADER}, but that's not the case. Where did I go wrong?
« Last Edit: February 14, 2007, 07:59:17 am by GauGau »
Logged

Nibbler

  • Guest
Re: Add php-content to template.html via {CUSTOM_HEADER}?
« Reply #1 on: February 13, 2007, 12:50:01 am »

You need to specify a path, not an URL. If that doesn't help then post a link and your code.
Logged

KidSnare

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Add php-content to template.html via {CUSTOM_HEADER}?
« Reply #2 on: February 13, 2007, 01:34:57 am »

Many thanks,

I specified the path, so the php file is now found, but instead I get an error. The php file looks like this:

<?php

echo <<<EOT

.....some php code here.....

      
EOT;

?>

and I get the error message:
Parse error: parse error, unexpected $ in /homepages/46/d19447377/htdocs/gallery/header.php on line 9
which is the last line ?>

I also tried to leave everything blank in between EOT, same error. Any ideas?

Logged

Nibbler

  • Guest
Re: Add php-content to template.html via {CUSTOM_HEADER}?
« Reply #3 on: February 13, 2007, 01:39:29 am »

Make sure you don't have any whitespace immediately after (on the same line as) the EOT;
Logged

KidSnare

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Add php-content to template.html via {CUSTOM_HEADER}?
« Reply #4 on: February 13, 2007, 08:37:35 am »

You mean like this?

....php code......
EOT;?>

I tired that but same error. This is confusing. ???
Logged

Nibbler

  • Guest
Re: Add php-content to template.html via {CUSTOM_HEADER}?
« Reply #5 on: February 13, 2007, 12:29:30 pm »

Can you post the actual code?
Logged

KidSnare

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Add php-content to template.html via {CUSTOM_HEADER}?
« Reply #6 on: February 13, 2007, 12:37:57 pm »

OK, this is what the header.php (I renamed it that way) looks like, that I want to add with {CUSTOM_HEADER} into template.html:

Code: [Select]
<?php

echo <<<EOT
$DatabaseHost = "xxxx";
$DatabaseUser = "xxxx";
$DatabasePassword = "xxxx";
$Database = "xxxx";
$TableDates = "Dates";

MYSQL_CONNECT(
$DatabaseHost$DatabaseUser$DatabasePassword) or die ( "Datenbankserver nicht erreichbar");

MYSQL_SELECT_DB(
$Database) or die ( "Datenbank nicht vorhanden");
$Result=MYSQL_QUERY( "SELECT Datum, Ort, CURRENT_DATE, DATE_FORMAT(Datum, '%d.%m.') as 'DateFormat' FROM $TableDates
WHERE CURRENT_DATE < Datum ORDER BY Datum DESC LIMIT 6
");

if(mysql_num_rows(
$Result)>0)
{
for(
$i=0; $i<mysql_num_rows($Result); $i++)
{
$Daten = mysql_fetch_object($Result);
echo"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">",
"<tr>",
"<td>",
$Daten->DateFormat,
"</td>",
"<td>&nbsp;",
"</td>",
"<td>",
$Daten->Ort,
"</td>",
"</tr>",
"</table>";
}
}
else
{
echo"Keine aktuellen Dates in der Datenbank.";
}

echo"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">",
"<tr>",
"<td>&nbsp;",
"</td>",
"</tr>",
"<tr>",
"<td><a href=\"contact.php\">Contact und Booking</a>",
"</td>",
"</tr>",
"</table>";
EOT;?>

Logged

Nibbler

  • Guest
Re: Add php-content to template.html via {CUSTOM_HEADER}?
« Reply #7 on: February 13, 2007, 12:40:24 pm »

You need a new line after the EOT; but no space between the semi colon and the newline.
Logged

KidSnare

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Add php-content to template.html via {CUSTOM_HEADER}?
« Reply #8 on: February 13, 2007, 01:11:53 pm »

Many thanks for your fast answers, I really appreciate it!
Now there's no error message, but in the table where the php-stuff should be it shows only {CUSTOM_HEADER}.
I think we're close, maybe I have to alter the table in the template.html somehow?

It looks like this:

Code: [Select]
<tr>
     <td bgcolor="#002200" align="left">{CUSTOM_HEADER}</td>
    </tr>
Logged

Nibbler

  • Guest
Re: Add php-content to template.html via {CUSTOM_HEADER}?
« Reply #9 on: February 13, 2007, 02:00:22 pm »

Make sure your {CUSTOM_HEADER} is above {GALLERY}. If it is not then you need to use a custom footer instead.
Logged

KidSnare

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Add php-content to template.html via {CUSTOM_HEADER}?
« Reply #10 on: February 14, 2007, 01:23:52 am »

Thanks again, it worked...almost worked.

What happened now is that the php code of the Custom Footer is shown in clear letters inside the table.
Please take a look at the code above, how do I have to change notation to make it work?

Many thanks so far
-Kid
Logged

KidSnare

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Add php-content to template.html via {CUSTOM_HEADER}?
« Reply #11 on: February 14, 2007, 01:57:13 am »

OK, problem solved!
I just removed the EOT-Tags....and it worked. Thought this notation was mandatory for the custom header/footer, but it seems I got something wrong at that point in the FAQ.

Thanks to Nibbler, you have been a great help. :)
Logged
Pages: [1]   Go Up
 

Page created in 0.026 seconds with 20 queries.