|
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 |
anka Smarty n00b
Joined: 09 Dec 2009 Posts: 1
|
Posted: Wed Dec 09, 2009 1:23 pm Post subject: wyświetlenie tekstu z pliku |
|
|
Mam taki problem: chcę przekazać do szablonu tekst zawarty w pliku (w bazie danych).
Teraz szablon includuje plik ({include file="sciezka_do_pliku"}) ale ja chcę, żeby do szablonu był przekazywany już sam tekst, bo muszę go 'potraktować' modyfikatorem truncate.
W tej chwili mam coś takiego:
klasa tekstfile() zawira metodę readFileContent():
Code: |
function readFileContent() {
if (file_exists($this->fileUsed) && (filesize($this->fileUsed))) {
$handle = fopen($this->fileUsed,"r");
$content = fread($handle,filesize($this->fileUsed));
fclose ($handle);
return trim($content);
} else {
return "";
}
}
|
index.php
Code: |
$tempTab = $listOfDates->GetList();
$string='E://xampp/htdocs/serwis/terminarz/';
for( $i = 0, $last = count( $tempTab ); $i < $last; $i++ )
{
$zajawka= new TextFile($string,$tempTab[$i][3]);
}
$zajawka= new TextFile($string,$tempTab[$i][3]);
$smarty->assign('tekst',$zajawka->readFileContent);
|
index.tpl
Code: |
{section name='list1' loop=$listOfNews}
...
{$tekst[list1][3]}
...
{/section}
|
na razie nie daję truncate bo mi nie chce wcale wyświetlić
Proszę o pomoc bo siedzę nad tym cały dzień i nie mam pojęcia co robię źle |
|
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
|