coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 themes/skins/templates => Topic started by: KidSnare on February 13, 2007, 12:46:22 AM

Title: Add php-content to template.html via {CUSTOM_HEADER}?
Post by: KidSnare 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?
Title: Re: Add php-content to template.html via {CUSTOM_HEADER}?
Post by: Nibbler 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.
Title: Re: Add php-content to template.html via {CUSTOM_HEADER}?
Post by: KidSnare 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?

Title: Re: Add php-content to template.html via {CUSTOM_HEADER}?
Post by: Nibbler 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;
Title: Re: Add php-content to template.html via {CUSTOM_HEADER}?
Post by: KidSnare on February 13, 2007, 08:37:35 AM
You mean like this?

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

I tired that but same error. This is confusing. ???
Title: Re: Add php-content to template.html via {CUSTOM_HEADER}?
Post by: Nibbler on February 13, 2007, 12:29:30 PM
Can you post the actual code?
Title: Re: Add php-content to template.html via {CUSTOM_HEADER}?
Post by: KidSnare 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:

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


Title: Re: Add php-content to template.html via {CUSTOM_HEADER}?
Post by: Nibbler 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.
Title: Re: Add php-content to template.html via {CUSTOM_HEADER}?
Post by: KidSnare 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:

<tr>
     <td bgcolor="#002200" align="left">{CUSTOM_HEADER}</td>
    </tr>
Title: Re: Add php-content to template.html via {CUSTOM_HEADER}?
Post by: Nibbler 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.
Title: Re: Add php-content to template.html via {CUSTOM_HEADER}?
Post by: KidSnare 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
Title: Re: Add php-content to template.html via {CUSTOM_HEADER}?
Post by: KidSnare 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. :)