![]() |
![]() |
![]()
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%) ![]() ![]() |
cos takiego?
[php:1:5015775afd]<?php $if_lookfor = '<if condition='; $if_location = -1; $if_end_lookfor = '</if>'; $if_end_location = -1; $if_location = strpos($template, $if_lookfor, $if_end_location + 1); if ($if_location === false) { break; } $zmienna_start = $if_location + strlen($if_lookfor) + 2; $delimiter = $template[$zmienna_start - 1]; if ($delimiter != '"' AND $delimiter != ''') { $if_end_location = $if_location + 1; continue; } $if_end_location = strpos($template, $if_end_lookfor, $zmienna_end + 3); if ($if_end_location === false) { return str_replace("'", ''', $template); } for ($i = $zmienna_start; $i < $strlen; $i++) { if ($template["$i"] == $delimiter AND $template[$i - 2] != '' AND $template[$i + 1] == '>') { $zmienna_end = $i - 1; break; } } $zmienna = substr($template, $zmienna_start, $zmienna_end-$zmienna_start); ?>[/php:1:5015775afd] |
|
|
![]() ![]() |
![]() |
Aktualny czas: 5.10.2025 - 09:04 |