Add php-content to template.html via {CUSTOM_HEADER}? Add php-content to template.html via {CUSTOM_HEADER}?
 

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]

Main Menu

Add php-content to template.html via {CUSTOM_HEADER}?

Started by KidSnare, February 13, 2007, 12:46:22 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

KidSnare

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?

Nibbler

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

KidSnare

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?


Nibbler

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

KidSnare

You mean like this?

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

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


KidSnare

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:

<?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;?>



Nibbler

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

KidSnare

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:

<tr>
     <td bgcolor="#002200" align="left">{CUSTOM_HEADER}</td>
    </tr>

Nibbler

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

KidSnare

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

KidSnare

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. :)