|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
holunda Smarty Rookie
Joined: 27 Jun 2003 Posts: 28 Location: Austria > Tyrol
|
Posted: Mon Jun 30, 2003 10:04 pm Post subject: problem with include_php |
|
|
Hello
I have a big problem
I have 2 templates (header.tpl,footer.tpl) looks like this:
header.tpl
-----------
<html>
<head></head>
<body>
{$nav}
footer.tpl
-----------
</body>
</html>
When i want to create a new site i make a new template and a new php site. Thats my problem. My Navigation is created by a MySQL Database and so i have to write code for output my nav on every new site. Thats silly. How could i make a php site and include it into header.tpl???
i tried it but it did not work.
thx and best wishes.
Alex |
|
Back to top |
|
holunda Smarty Rookie
Joined: 27 Jun 2003 Posts: 28 Location: Austria > Tyrol
|
Posted: Tue Jul 01, 2003 11:10 am Post subject: |
|
|
It is very very urgent, please Can Somebody help me?
The PHP Code i have to write on every Site is like this:
include ("database.class.php");
$db = new class_database(); // Database Engine instanziert
$erg = $db->query("SELECT warengruppe_id,bezeichnung FROM warengruppe");
while ($record = mysql_fetch_array($erg)){
$kategorie[] = $record;
}
// Kategorie Menü darstellen
$tpl->assign('kategorie',$kategorie);
################################################ |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Jul 01, 2003 12:28 pm Post subject: |
|
|
yep, everything is urgent nowadays.
how to reuse php-code for navigation? as your subject suggests with include_php:
http://smarty.php.net/manual/en/language.function.include.php.php
just keep in mind that your smarty-object is always $this inside the included php-file (and not $tpl) and that you have to declare variables
as global if you want to use them from outside the included php-file.
HTH
messju |
|
Back to top |
|
holunda Smarty Rookie
Joined: 27 Jun 2003 Posts: 28 Location: Austria > Tyrol
|
Posted: Wed Jul 02, 2003 7:16 am Post subject: |
|
|
hi messju,
thank your for your reply. I tried to use include_php, but it didn't work.
I created a menue.tp
------------------------
Code: |
{include_php file="menue.inc.php"}
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="titel">MvO-Kosmetik</td>
</tr>
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td class="navi">{section name=kat loop=$kategorie}<a href="katalog.php?warengruppe_id={$kategorie[kat].warengruppe_id}" class="navi">{$kategorie[kat].bezeichnung}</a> | {/section} <a href="favoriten.php" class="navi">Favoriten</a></td>
<td align="right" class="navi"><a href="konto.php" class="navi">Mein Konto</a> | <a href="warenkorb.php" class="navi">Warenkorb</a></td>
</tr>
</table>
</td>
</tr>
</table> |
I include this menue Template in m< header.tp.
The Engine puts out an error: Cannot read Template source.
What do i make wrong? |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|