![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 156 Pomógł: 15 Dołączył: 13.09.2003 Skąd: London Ostrzeżenie: (0%) ![]() ![]() |
Mam taka funkcje:
[php:1:29914852a5]<?php function gettemplate($templatename, $gethtmlcomments = 1) { if(file_exists("templates/$templatename.htm")){ $fd = fopen ("templates/$templatename.htm", "r"); $template_file = fread ($fd, filesize ("templates/$templatename.htm")); $template = preg_replace_callback('/{_([^ ]+)}/U', create_function('$matchs', 'return $GLOBALS["lang_$matchs[1]"];'), $template_file); $template = preg_replace_callback('/{([^ ]+)}/U', create_function('$matches', 'return $GLOBALS[$matches[1]];'), $template); if ($options['addtemplatename'] = 1 AND $gethtmlcomments = 1) { $template = "n<!-- POCZATEK SZABLONU: $templatename -->n$templaten<!-- KONIEC SZABLONU: $templatename -->n"; } fclose($fd); return $template; } else { return "<center><font color="red">Wystapil blad krytyczny - Brak szablonu '$tplfile'. Skontaktuj sie z administratorem.</font></center>"; } } ?>[/php:1:29914852a5] Chce miec mozliwosc dodania do szablonu czegos takiego: Kod <if condition="$show"> tutaj tresc strony </if>
i jesli funkcja natrafi na taki kod zeby sprawdzila czy np. $show == 1, a jesli tak to wyswietlila kod miedzy znacznikiem <if></if>. Ma ktos pomysl jak to zrobic? (IMG:http://forum.php.pl/style_emoticons/default/sad.gif) widze, ze chyba nikt (IMG:http://forum.php.pl/style_emoticons/default/sad.gif) |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 156 Pomógł: 15 Dołączył: 13.09.2003 Skąd: London Ostrzeżenie: (0%) ![]() ![]() |
Jeszcze jedno
[php:1:4ba3768875] <?php $template = preg_replace("/<if condition="(.*?)">(.+?)</if>/sie", "eval("return ('1' == true) ? '2' : '';")", $template); ?> [/php:1:4ba3768875] i dziala dobrze w przypadku zwyklych zmiennych. No ale wywala blad: Kod Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:usrkrasnalwwwcms_funkcje.php(54) : regexp code on line 1
Fatal error: Failed evaluating code: eval("return ('$show['coppa']' == true) ? ' Zalogowany ' : ' Niezalogowany :) ';") in c:usrkrasnalwwwcms_funkcje.php on line 54 jak w szablonie zrobie [xml:1:4ba3768875]<if condition="$show['cos']">dfdfdfd</if>[/xml:1:4ba3768875] bez ['cos'] wszystko jest ok. Ktos wie jak to naprawic? |
|
|
![]() ![]() |
![]() |
Aktualny czas: 3.10.2025 - 05:20 |