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

Überprüft bitte meinen Code.

 
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 -> Language: German
View previous topic :: View next topic  
Author Message
oskarr
Smarty n00b


Joined: 25 Oct 2004
Posts: 3

PostPosted: Mon Oct 25, 2004 2:10 pm    Post subject: Überprüft bitte meinen Code. Reply with quote

[php:1:fccba57f4b]

<?php
//Classen includieren//
require_once './classes/Smarty.class.php';
//Neues Smarty starten =)//
$smarty = new Smarty;
//Smartysetup//
$smarty->compile_check = false;
$smarty->debugging = false;
//Inhalt zu Smarty zuweisen//
include_once('./configs/bereichconfig.php');
if(isset($_GET['section']) AND isset($dateien[$_GET['section']]))
{
//Ist eine $_GET Variable vorhanden wird PHP angewiesen
//zu prüfen ob die Datei existiert und diese dann zu laden

if(!file_exists($dateien[$_GET['section']]));
$datei=require $dateien[$_GET['section']];
$smarty->assign("mainbody","$datei");
}
else {
$home=require ('home.php');
$smarty->assign("mainbody","$home");
}
//Titel//
$smarty->assign("TITLE","index.php von localhost");
//Ausgabe im Template//
$smarty->display('index.tpl');

?>[/php:1:fccba57f4b]
Wenn man später, die Abfrage stattfindet, was denn für eine Getvariable übermittelt wurde, wird dann in meinem Template als Mainbody ein File includiert. Das funktioniert so an sich gut, aber, wenn man sich dann die Seite ansieht, taucht auf einmal in dem nach dem Satz aus dem Includefile eine 1 auf, woran kann es liegen?
Back to top
View user's profile Send private message
b166-er
Smarty Rookie


Joined: 22 Oct 2004
Posts: 29
Location: Germany, Wiesbaden

PostPosted: Mon Oct 25, 2004 2:25 pm    Post subject: Reply with quote

Smile
ganz einfach, weil man den output von require()-funktion nicht in eine variable speichern kann. deshalb gibt es nur eine 1 zurueck, also ein TRUE, das dein require befehl, die datei includen konnte.
wenn du in smarty dateien includen moechtest, dann nimm smarty funktion:
{include ...} siehe manual

und noch ne anmerkung zum code:
falsch/schlecht: [php]<?php $smarty->assign("mainbody","$home"); ?>[/php]
gut: [php]<?php $smarty->assign('mainbody',$home); ?>[/php]
hier die erklaerung dazu: http://www.php-faq.de/q/q-fehler-konstante.html

viel glueck
________
Twin cities assembly plant


Last edited by b166-er on Sun Feb 13, 2011 6:18 pm; edited 1 time in total
Back to top
View user's profile Send private message
oskarr
Smarty n00b


Joined: 25 Oct 2004
Posts: 3

PostPosted: Mon Oct 25, 2004 2:33 pm    Post subject: Reply with quote

Danke sehr, und wie kann ich das ganze anders umschreiben, damit die 1 nicht mehr auftaucht? Ich habe die Variablen weggemacht, aber die 1 taucht trotzdem auf. =)[php:1:d9ac816842]
<?php
//Classen includieren//
require_once './classes/Template.class.php';
//Neues Smarty starten =)//
$smarty = new Smarty;
//Smartysetup//
$smarty->compile_check = false;
$smarty->debugging = false;
//Inhalt zu Smarty zuweisen//
include_once('./configs/bereichconfig.php');
if(isset($_GET['section']) AND isset($dateien[$_GET['section']]))
{
//Ist eine $_GET Variable vorhanden wird PHP angewiesen
//zu prüfen ob die Datei existiert und diese dann zu laden

if(!file_exists($dateien[$_GET['section']]));
$smarty->assign("mainbody",include $dateien[$_GET['section']]);
}
else {
$smarty->assign("mainbody",include ('home.php'));
}
//LOL//
$smarty->assign("TITLE","index.php von localhost");
//Ausgabe im Template//
$smarty->display('index.tpl');

?>[/php:1:d9ac816842]
Back to top
View user's profile Send private message
kills
Smarty Elite


Joined: 28 May 2004
Posts: 493

PostPosted: Mon Oct 25, 2004 2:40 pm    Post subject: Reply with quote

Wie wärs damit?

[php:1:17155e934f]
<?php
//Classen includieren//
require_once './classes/Template.class.php';
//Neues Smarty starten =)//
$smarty = new Smarty;
//Smartysetup//
$smarty->compile_check = false;
$smarty->debugging = false;
//Inhalt zu Smarty zuweisen//
include_once('./configs/bereichconfig.php');
if(isset($_GET['section']) AND isset($dateien[$_GET['section']]))
{
//Ist eine $_GET Variable vorhanden wird PHP angewiesen
//zu prüfen ob die Datei existiert und diese dann zu laden

$maintpl = 'home.php';
if( file_exists($dateien[$_GET['section']]));
$maintpl = $dateien[$_GET['section']];
}

$smarty->assign("maintpl", $maintpl);

//LOL//
$smarty->assign("TITLE","index.php von localhost");
//Ausgabe im Template//
$smarty->display('index.tpl');

?>

[/php:1:17155e934f]

und im template dann

Code:


{ include_php file=$maintpl }

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 -> Language: German 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