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

Display i zera po przeparsowaniu zmiennych

 
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: Polish
View previous topic :: View next topic  
Author Message
m1chu
Smarty Rookie


Joined: 22 Jun 2008
Posts: 5

PostPosted: Sun Jun 22, 2008 1:02 pm    Post subject: Display i zera po przeparsowaniu zmiennych Reply with quote

Witam serdecznie.

Załączam wartości do szablonu poprzez assign(), po czym chcę wyświetlić przeparsowany szablon poprzez display(). I tu rodzi się problem, bo pomimo, że w assign() dołączam kolejne wartości prawidłowo, to po wykonaniu display() mam kod strony z załączanego pliku (dla przykładu niech to będzie index.html), ale miejsca w których zamieszczam zmienne Smarty (dla przykładu {$abc}) są zamieniane przez zera, a nie wartości które nadałem w assign().

Żeby zobrazować sytuację. Plik index.php:
Code:
$smarty = new Smarty();
$smarty->template_dir = 'styles/abc/';
$smarty->compile_dir = 'styles_c/abc/';
$smarty->cache_dir = '.cache/';
$smarty->config_dir = 'configration/';
$smarty->caching = false; // dla true wynik jest identyczny

// obydwie wartości są typu string - wyświetlenie ich na ekranie przed, czy po assign() potwierdza ich zawartość
$smarty->assign('keywords', $engineInstance->settings->keywords);
$smarty->assign('description', $engineInstance->settings->description);

$smarty->debugging = true;

$smarty->display('index.html');

I plik index.html w katalogu styles/abc/:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html lang="pl" xml:lang="pl" xmlns="http://www.w3.org/1999/xhtml">
<head>
   <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
   <meta name="keywords" content="{$keywords}" />
   <meta name="description" content="{$description}" />
   <title>Test</title>
</head>

<body>
Test
</body>
</html>

Jak widać został dodatkowo włączony tryb debugowania, którego wynikiem jest:
Code:
assigned template variables
{$SCRIPT_NAME}    "/temp/"
{$description}     "opis strony"
{$keywords}    "słowa, kluczowe"

Wchodząc pod adres skryptu otrzymuje taki kod źródłowy:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html lang="pl" xml:lang="pl" xmlns="http://www.w3.org/1999/xhtml">
<head>
   <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
   <meta name="keywords" content="0" /> // dopiska autora: powinno być "słowa, kluczowe"
   <meta name="description" content="0" /> // dopiska autora: powinno być "opis strony"
   <title>Test</title>
</head>

<body>
Test
</body>
</html>

Jakieś propozycje, gdzie może leżeć błąd? Albo co robię źle?
Back to top
View user's profile Send private message
m1chu
Smarty Rookie


Joined: 22 Jun 2008
Posts: 5

PostPosted: Sun Jun 22, 2008 5:07 pm    Post subject: Reply with quote

Ok. Rozwiązane Very Happy Nie bijcie, ale przeoczyłem fakt, że użycie w nazwie Smarty-owskiej zmiennej czegoś w stylu "abc-nazwa" powoduje, że abc jest brane jako prefix, dlatego źle parsowało mi szablon. Dopiero po usunięciu pomijania E_NOTICE w wyświetlaniu błędów to zobaczyłem.

Jeszcze raz sorry za problem Very Happy
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: Polish 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