我想在 CSCART 的管理面板中开发一个新页面。我制作了一个控制器pincode.php和模式'add'并在views中创建了一个tpl add.tpl。当一个调用'admin .PHP?调度= pincode.add”。它给出了一个http错误。
控制器(cscart \应用\控制器\后端\ pincode.php)
<?php
use Tygh\Registry;
if (!defined('BOOTSTRAP')) { die('Access denied'); }
if ($mode == 'add') {
Registry::get('view')->display('views/pincode/add.tpl');
}
?>
查看(cscart \设计\后端\模板\视图\ pin码\ add.tpl):
<form action="" method="post" name="add_form">
<input type="text" name="pincode" />
<input type="text" name="city" />
<input type="text" name="state" />
</form>
当我在控制器中放置echo die时,它会显示回声内容。
答案 0 :(得分:2)
最好创建一个名为pincode的新附加组件(你可以生成一个here),这将是你准备好的升级;)
cscart/app/addons/pincode/controllers/backend/pincode.php
<?php
/*
* © 2015 Hungryweb
*
* @website: www.hungryweb.net
* @support: support@hungryweb.net
*
*/
if ( !defined('BOOTSTRAP') ) { die('Access denied'); }
use Tygh\Registry;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
fn_trusted_vars (
'pincode'
);
if ($mode == 'update') {
if (isset($_REQUEST['pincode'])) {
#add your code
print_r($_REQUEST['pincode']);
exit;
}
}
}
if ($mode == 'update') {
$pincode = array();
$pincode['pin'] = '';
$pincode['city'] = '';
$pincode['state'] = '';
Registry::get('view')->assign('pincode', $pincode);
}
cscart/design/backend/templates/addons/pincode/views/pincode/update.tpl
带有内容的{capture name="mainbox"}
<form action="{""|fn_url}" method="post" name="pincode_update_form" class="form-horizontal form-edit">
{include file="common/subheader.tpl" title=__("information") target="#pincode_information_setting"}
<div id="pincode_information_setting" class="in collapse">
<fieldset>
<div class="control-group">
<label for="elm_pincode" class="control-label cm-required">{__("pincode_field")}:</label>
<div class="controls">
<input type="text" name="pincode[pin]" id="elm_pincode" size="55" value="{$pincode.pin}" class="input-large" />
</div>
</div>
<div class="control-group">
<label for="elm_city" class="control-label cm-required">{__("city")}:</label>
<div class="controls">
<input type="text" name="pincode[city]" id="elm_city" size="55" value="{$pincode.city}" class="input-large" />
</div>
</div>
<div class="control-group">
<label for="elm_state" class="control-label cm-required">{__("state")}:</label>
<div class="controls">
<input type="text" name="pincode[state]" id="elm_state" size="55" value="{$pincode.state}" class="input-large" />
</div>
</div>
</fieldset>
</div>
{capture name="buttons"}
{assign var="hide_first_button" value=false}
{assign var="hide_second_button" value=true}
{include file="buttons/save_cancel.tpl" but_name="dispatch[pincode.update]" hide_first_button=$hide_first_button hide_second_button=$hide_second_button but_target_form="pincode_update_form"}
{/capture}
</form>
{/capture}
{capture name="sidebar"}
<div class="sidebar-row">
<h6>{__("pages")}</h6>
<div class="nested-tree">
Maybe you need ;)
</div>
</div>
{/capture}
{include file="common/mainbox.tpl" title=__('pincode_update') sidebar=$smarty.capture.sidebar sidebar_position="right" content=$smarty.capture.mainbox buttons=$smarty.capture.buttons adv_buttons=$smarty.capture.adv_buttons}
带有此CS-Cart插件的zip存档可以从here
下载我希望有所帮助,
答案 1 :(得分:1)
只需将add.tpl重命名为update.tpl fn.control.php 文件中有一段代码:
if ($mode == 'add') {
$tpl = 'update.tpl';
} elseif (strpos($mode, 'add_') === 0) {
$tpl = str_replace('add_', 'update_', $mode) . '.tpl';
} else {
$tpl = $mode . '.tpl';
}