ребят пытаюсь передать переменные php в шаблон smarty прописываю в php Код (PHP): <?php define("CLIENTAREA",true); //define("FORCESSL",true); // Uncomment to force the page to use https:// require_once("init.php"); $whmcs = App::getinstance(); $whmcs->load_function('client'); $ca = new WHMCS_ClientArea(); $result=mysql_query("SELECT url,text,colors_s,colors_op FROM tb_ads_100x100 ORDER BY rand() LIMIT 15"); $data=mysql_fetch_array($result); $text=$data['text']; $url=$data['url']; $colors_s=$data['colors_s']; $colors_op=$data['colors_op']; $ca->assign('text', $text); $ca->assign('url', $url); $ca->assign('colors_s', $colors_s); $ca->assign('colors_op', $colors_op); $ca->setTemplate('header'); $ca->output(); ?> затем в шаблон прописываю Код (PHP): {include_php file="ads_header.php"} <div class="curved-hz-1"> <div class="viz b-blockWithTab__title_text" > <p><font color="{$colors_op}"><b>{$text}</b></font></p><br> <p style="margin-top:-50px; padding-left:15px"> <a href="{$url}" target="_blank"> <font color="{$colors_s}"><b>{$url}</b></font></a></p> </div></div> получаю такую ошибку как исправить?
Он тебе указывает конкретную строку конкретного файла где ты переменную для шаблона определяешь, в чем проблема? Дамп объекта выводить не умеешь?
Zuldek проблема в том что везде работает assign, а создал новый модуль, прописал в нем все верно решил проверить тупо вывести в шаблон так Код (PHP): {php} $result=mysql_query("SELECT url,text,colors_s,colors_op FROM tb_ads_100x100 ORDER BY rand() LIMIT 15"); $data=mysql_fetch_array($result); $text=$data['text']; $url=$data['url']; $colors_s=$data['colors_s']; $colors_op=$data['colors_op']; var_dump($text); {/php} все выводит все норм, а вот через вывод из smarty в шаблонизатор не выводит, он указывает мне ошибку так Fatal error: Call to a member function assign() on a non-object in W:\domains\net.su\includes\classes\WHMCS\ClientArea.php on line 0 ну файл ClientArea.php зашифрован.... просто не оч понятно почему не работает, например я писал такой код Код (PHP): define('CLIENTAREA', true); require("init.php"); if(isset($_SESSION['uid'])){ $whmcs = App::getinstance(); $whmcs->load_function('client'); $smarty = new Smarty(); $smarty->assign('template', $CONFIG['Template']); $smarty->assign('LANG', $_LANG); // $smarty->assign('logo', $CONFIG['LogoURL']); // $smarty->assign('companyname', $CONFIG['CompanyName']); // $smarty->assign('Email', $CONFIG['Email']); $logo = $CONFIG['LogoURL']; $CompanyName = $CONFIG['CompanyName']; $Email = $CONFIG['Email']; $smarty->assign('pagetitle', $_LANG['clientareaemails']); checkContactPermission('emails'); $id = (int) $whmcs->get_req_var('id'); $result = select_query('tblemails', '', array( 'id' => $id, 'userid' => (int) $_SESSION['uid'] )); $data = mysql_fetch_array($result); $date = $data['date']; $subject = $data['subject']; $message = $data['message']; $date = fromMySQLDate($date, 'time'); // $smarty->assign('date', WHMCS_Input_Sanitize::makesafeforoutput($date)); // $smarty->assign('subject', WHMCS_Input_Sanitize::makesafeforoutput($subject)); // $smarty->assign('message', $message); // $template_output = $smarty->fetch($whmcs->getClientAreaTplName() . "/mail.tpl"); // echo $template_output; $arr['msg'] = $message; $arr['sbj'] = $subject; $arr['comp'] = $CompanyName; $arr['logourl'] = $logo_url; $arr['email'] = $Email; echo json_encode($arr); }else{ redir("index.php"); } он все выводит и все работает, так почему тогда выше указанный не работает?
Здесь у вас есть инициализация smarty и шаблона и далее вызовы асигнов. А в первом случае у вас всё идёт через объект другого класса. Поэтому нужно смотреть использование этой обвязки в проекте если у вас по каким-то причинам нет возможности посмотреть исходники используемого класса.
Zuldek получается надо так? Код (PHP): define('CLIENTAREA', true); require_once("init.php"); $whmcs = App::getinstance(); $whmcs->load_function('client'); $smarty = new Smarty(); $result=mysql_query("SELECT url,text,colors_s,colors_op FROM tb_ads_100x100 ORDER BY rand() LIMIT 15"); $data=mysql_fetch_array($result); $text=$data['text']; $url=$data['url']; $colors_s=$data['colors_s']; $colors_op=$data['colors_op']; $smarty->assign('text', $text); $smarty->assign('url', $url); $smarty->assign('colors_s', $colors_s); $smarty->assign('colors_op', $colors_op); $smarty->setTemplate('header'); $smarty->output();