Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

problem with include_php

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
holunda
Smarty Rookie


Joined: 27 Jun 2003
Posts: 28
Location: Austria > Tyrol

PostPosted: Mon Jun 30, 2003 10:04 pm    Post subject: problem with include_php Reply with quote

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
View user's profile Send private message
holunda
Smarty Rookie


Joined: 27 Jun 2003
Posts: 28
Location: Austria > Tyrol

PostPosted: Tue Jul 01, 2003 11:10 am    Post subject: Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Tue Jul 01, 2003 12:28 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
holunda
Smarty Rookie


Joined: 27 Jun 2003
Posts: 28
Location: Austria > Tyrol

PostPosted: Wed Jul 02, 2003 7:16 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP