katrukhin Posted April 26, 2012 Report Share Posted April 26, 2012 Добрый день, я не мастер написания скриптов, но прочитав пару уроков написал свой парсер валютfunction currency(){ $q = date("d.m.Y");$q = str_replace(" ","+",$q);$h = curlFunc('http://www.cbr.ru/currency_base/D_print.aspx?date_req='.$q); $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_URL, $h); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);$result = curl_exec($ch); curl_close($ch);preg_match_all('/<td align="right">(.*?)<\/td>/is', $h, $matches);$usd = $matches[1][29];$eur = $matches[1][32];$cyn = $matches[1][47];}Плохой, не плохой, дело не в этом. Факт в том что работает.Стала проблема внедрить данный код в симплу.На SMARTY написано что я могу и в шаблоне кусочек вставить PHP используя вот такой синтаксис {php}.Но как только его видит Simpla 2, то сразу Fatal Error.Могу я прописать не кую функцию в код сайта и вызвать ее, как это возможно, есть ли некая документация? Quote Link to post Share on other sites
iluwka Posted April 26, 2012 Report Share Posted April 26, 2012 в конфиге включи возможность вставки пхп Quote Link to post Share on other sites
subLane Posted June 9, 2012 Report Share Posted June 9, 2012 как именно и где это сделать подскажите плз тоже очень интересует данный вопрос Quote Link to post Share on other sites
phpmaster Posted June 10, 2012 Report Share Posted June 10, 2012 php-код вставляется между {php} и {/php} Quote Link to post Share on other sites
strannik22 Posted June 15, 2012 Report Share Posted June 15, 2012 заменил на true.вставил в шаблоне {php} <?php include("left.php")?> {/php}выводит - Parse error: syntax error, unexpected '<' in ......... hosting.ru/public_html/Smarty/libs/plugins/block.php.php(23) : eval()'d code on line 1*случаем в Smarty/libs/Smarty.class.php не нужно поменять public $allow_php_templates = false; на public $allow_php_templates = true; ? Quote Link to post Share on other sites
strannik22 Posted June 15, 2012 Report Share Posted June 15, 2012 теперь вместо одной ошибки - стало 3.Warning: include(left.php) [function.include]: failed to open stream: No such file or directory in /home/u23961/domains/....hosting.ru/public_html/Smarty/libs/plugins/block.php.php(23) : eval()'d code on line 1Warning: include(left.php) [function.include]: failed to open stream: No such file or directory in /home/u23961/domains/...hosting.ru/public_html/Smarty/libs/plugins/block.php.php(23) : eval()'d code on line 1Warning: include() [function.include]: Failed opening 'left.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/u23961/domains/...hosting.ru/public_html/Smarty/libs/plugins/block.php.php(23) : eval()'d code on line 1 Quote Link to post Share on other sites
strannik22 Posted June 19, 2012 Report Share Posted June 19, 2012 сделал полный путь, вывод:Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/u23961/domains/...hosting.ru/public_html/Smarty/libs/plugins/block.php.php(23) : eval()'d code on line 1Warning: include(http://...hosting.ru/design/default_1/html/left.php) [function.include]: failed to open stream: no suitable wrapper could be found in /home/u23961/domains/...hosting.ru/public_html/Smarty/libs/plugins/block.php.php(23) : eval()'d code on line 1Warning: include() [function.include]: Failed opening 'http://...hosting.ru/design/default_1/html/left.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/u23961/domains/...hosting.ru/public_html/Smarty/libs/plugins/block.php.php(23) : eval()'d code on line 1 Quote Link to post Share on other sites
Kosjak76 Posted June 19, 2012 Report Share Posted June 19, 2012 Вообще-то в Симпле по-моему запрещена обработка РНР из папки дизайн, посмотрите .htacsses Quote Link to post Share on other sites
Чудилла Posted June 19, 2012 Report Share Posted June 19, 2012 там же шаблонизатор смарти, функцию можно написать на смарти, а сейчас получается говно код, ребятки Quote Link to post Share on other sites
Чудилла Posted June 19, 2012 Report Share Posted June 19, 2012 Как раз наоборот. Шаблонизатор автоматом делает из шаблона код PHP, который по качеству обычно много хуже кода, написанного вручную.Шаблонизатор смарти, по мне вообще говно, если использовать то уже фремворк. Quote Link to post Share on other sites
AndryFroggy Posted June 20, 2012 Report Share Posted June 20, 2012 Все прекрасно реализуется и в классах. Не надо лезть в смарти-настройки. Quote Link to post Share on other sites
osben Posted June 20, 2012 Report Share Posted June 20, 2012 передай через view.php результат своего парсера, и не делай кашу в смарти Quote Link to post Share on other sites
osben Posted June 20, 2012 Report Share Posted June 20, 2012 П.С. forloo - после твоего комента, заинтересовало что в твоём понимании фремворк и шаблонизатор, видать для тебя нет разницы? )))) Quote Link to post Share on other sites
xavior Posted June 6, 2014 Report Share Posted June 6, 2014 Обновлю тему. В версии 2.3.5 в смарти больше нет "public $allow_php_tag". Quote Link to post Share on other sites
xavior Posted July 4, 2014 Report Share Posted July 4, 2014 Чтобы включить старый добрый {php} ... {/php} идем в api/Design.php 4я строка меняем на require_once(dirname(dirname(__FILE__)).'/Smarty/libs/SmartyBC.class.php'); 15я строка меняем на $this->smarty = new SmartyBC() Quote Link to post Share on other sites
strannik22 Posted July 15, 2014 Report Share Posted July 15, 2014 Чтобы включить старый добрый {php} ... {/php} идем в api/Design.php 4я строка меняем на require_once(dirname(dirname(__FILE__)).'/Smarty/libs/SmartyBC.class.php'); 15я строка меняем на $this->smarty = new SmartyBC() поменял. вообще отключился сайт. Quote Link to post Share on other sites
xavior Posted July 15, 2014 Report Share Posted July 15, 2014 поменял. вообще отключился сайт.Это для версий от 2.3.5 и выше информация. для старых версий как включать - написано выше Quote Link to post Share on other sites
gl63amg Posted March 5, 2015 Report Share Posted March 5, 2015 Это для версий от 2.3.5 и выше информация. для старых версий как включать - написано вышеспасибо помогло Quote Link to post Share on other sites
Яша Posted January 25, 2020 Report Share Posted January 25, 2020 Всем доброго времени суток! Подскажите, пожалуйста. Мне нужно, чтобы на странице отзывов в меню выводился этот файл {include file='x_included_comments.tpl'}Я добавляю в админке на странице меню в текст страницы такой код {php}{include file='x_included_comments.tpl'}{/php}и в файле api/Design.php 4я строка меняем на require_once(dirname(dirname(__FILE__)).'/Smarty/libs/SmartyBC.class.php');15я строка меняем на $this->smarty = new SmartyBC()все это сделал, но на странице сайта появляется просто этот код {php}{include file='x_included_comments.tpl'}{/php}подскажите, как реализовать задуманное? Quote Link to post Share on other sites
Kasha Posted January 25, 2020 Report Share Posted January 25, 2020 Всем доброго времени суток! Подскажите, пожалуйста. Мне нужно, чтобы на странице отзывов в меню выводился этот файл {include file='x_included_comments.tpl'}Я добавляю в админке на странице меню в текст страницы такой код{php}{include file='x_included_comments.tpl'}{/php}и в файле api/Design.php 4я строка меняем на require_once(dirname(dirname(__FILE__)).'/Smarty/libs/SmartyBC.class.php');15я строка меняем на $this->smarty = new SmartyBC()все это сделал, но на странице сайта появляется просто этот код {php}{include file='x_included_comments.tpl'}{/php}подскажите, как реализовать задуманное?для того чтобы подтянуть .tpl не нужно прибегать к php, пользуйтесь просто {include file="x_included_comments.tpl"} без каких-либо других изменений и будет счастье Quote Link to post Share on other sites
Яша Posted March 29, 2020 Report Share Posted March 29, 2020 Спасибо) Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.