Prestashop 使用smarty-Prestahop从模板获取元素id

Prestashop 使用smarty-Prestahop从模板获取元素id,prestashop,smarty,Prestashop,Smarty,我在Prestashop用Smarty。在我的php文件中,我构建了如下函数: 公共函数hookDisplayAdminOrderContentOrder$params { $orderId=Tools::getValue'id_order';//mi prendo l'id dell'ordine per le查询sui docId $query='从'.\u DB\u前缀'.'orders'中选择docId1,docId1,其中id\u order=\.$orderId.'\';'; $d

我在Prestashop用Smarty。在我的php文件中,我构建了如下函数:

公共函数hookDisplayAdminOrderContentOrder$params { $orderId=Tools::getValue'id_order';//mi prendo l'id dell'ordine per le查询sui docId $query='从'.\u DB\u前缀'.'orders'中选择docId1,docId1,其中id\u order=\.$orderId.'\';'; $docId2=Db::getInstance\u PS\u USE\u SQL\u SLAVE\u->getRow$query['docId2']; $docId1=Db::getInstance\u PS\u USE\u SQL\u SLAVE\u->getRow$query['docId1']; $config\u CreaOrdine=Configuration::获取'PS\u CREAZIONE\u ORDINE'; $config_CreaFattura=Configuration::获取'PS_CREAZIONE_FATTURA'; //根据il contatore nel模板的uso订单文件 $order\u documents=0; 如果$docId1 | |$docId2 $order_documents++; 如果$docId1&&$docId2 $order_documents=2; 如果!$docId1{ $message_order='documento NON salvato'; $submit_button_id='submit_order'; $submit_label=Salva Ordine; }否则{ $message_order='documento salvato'; } 如果!$docId2{ $message_invoice='documento NON salvato'; $submit_button_id='submit_invoice'; $submit_label=Salva Fattura; }否则{ $message_invoice='documento salvato'; } smartyRegisterFunction$this->context->smarty,'function','saveDocument',array$this,'smartyDocument';//aggiungo la funzione per salvare di nuovo l'ordine $this->context->smarty->assign'id\u order',$orderId; $this->context->smarty->assign'config\u CreaOrdine',$config\u CreaOrdine; $this->context->smarty->assign'config\u CreaFattura',$config\u CreaFattura; $this->context->smarty->assign'order\u documents',$order\u documents;//contatore documenti salvati $this->context->smarty->assign'order',$message\u order; $this->context->smarty->assign'order_docId',$docId1;//docId per tasto ordine $this->context->smarty->assign'invoice',$message\u invoice; $this->context->smarty->assign'invoice_docId',$docId2;//docId per tasto fattura 返回$this->display___文件,'views/templates/hook/admin_content_order.tpl';
} 加载页面后,不能使用任何Smarty命令。您可以改用Javascript函数

Smarty是一个服务器端引擎,其输出在处理后发送到浏览器,这是一个相当静态的过程

您必须具有Javascript函数才能通过Ajax保存文档:

将数据发送到PHP 保存数据 返回成功或失败消息
好的,我改变主意了,现在我想从admin_order.tpl调用'smartyOrder'函数。我应该编辑这个问题还是问一个新问题更好?题目很相似,新问题是一个更好的选择。别忘了添加javascript函数