ecshop 生成商品代码
时间:2023年06月02日
/来源:网络
/编辑:佚名
一:特效:
二:生成代码界面:
复制代码
<form name="theForm" method="post" action="">
<table cellspacing="1" cellpadding="3" width="100%">
<tr>
<td class="label">{$lang.label_category}</td>
<td><select name="category" id="category">
<option value="0" selected>{$lang.all_category}</option>
{$cat_list}
</select></td>
</tr>
<tr>
<td class="label">{$lang.label_brand}</td>
<td><select name="brand" id="brand">
<option value="0" selected>{$lang.all_brand}</option>
{html_options options=$brand_list}
</select></td>
</tr>
<tr>
<td class="label">{$lang.label_intro_type}</td>
<td><select name="intro_type" id="intro_type">
<option value="all" selected>{$lang.all_intro_type}</option>
{html_options options=$intro_list}
</select></td>
</tr>
<tr>
<td class="label">{$lang.label_need_image}</td>
<td> <label>
<select name="need_image" id="need_image">
<option value="true" selected>{$lang.need}</option>
<option value="false">{$lang.need_not}</option>
</select>
</label></td>
</tr>
<tr>
<td class="label">{$lang.label_goods_num}</td>
<td><input name="goods_num" type="text" id="goods_num" value="1" /></td>
</tr>
<tr>
<td class="label">{$lang.label_arrange}</td>
<td><select name="arrange" id="arrange">
<option value="h" selected>{$lang.horizontal}</option>
<option value="v">{$lang.verticle}</option>
</select></td>
</tr>
<tr>
<td class="label">{$lang.label_rows_num}</td>
<td><input name="rows_num" type="text" id="rows_num" value="1" /></td>
</tr>
<tr>
<td class="label">{$lang.label_charset}</td>
<td><select name="charset" id="charset">
{html_options options=$lang_list}
</select></td>
</tr>
<tr>
<td class="label">{$lang.label_sitename} 1111</td>
<td><input name="sitename" type="text" id="sitename"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="button" class="button" name="gen_code" value="{$lang.generate}" onclick="genCode()" /> </td>
</tr>
<tr>
<td colspan="2" align="center"><textarea name="code" cols="80" rows="5" id="code"></textarea></td>
</tr>
</table>
</form>
复制代码
复制代码
<script language="JavaScript">
var elements = document.forms['theForm'].elements;
var url = '{$url}';
function genCode()
{
// 检查输入
if (isNaN(parseInt(elements['goods_num'].value)))
{
alert(goods_num_must_be_int);
return;
}
if (elements['goods_num'].value < 1)
{
alert(goods_num_must_over_0);
return;
}
if (isNaN(parseInt(elements['rows_num'].value)))
{
alert(rows_num_must_be_int);
return;
}
if (elements['rows_num'].value < 1)
{
alert(rows_num_must_over_0);
return;
}
// 生成代码
var code = '\<script src=\"' + url + 'goods_script.php?';
if (elements['category'].value > 0)
{
code += 'cat_id=' + elements['category'].value + '&';
}
if (elements['brand'].value > 0)
{
code += 'brand_id=' + elements['brand'].value + '&';
}
if (elements['intro_type'].value != 'all')
{
code += 'intro_type=' + elements['intro_type'].value + '&';
}
code += 'need_image=' + elements['need_image'].value + '&';
code += 'goods_num=' + elements['goods_num'].value + '&';
code += 'arrange=' + elements['arrange'].value + '&';
code += 'rows_num=' + elements['rows_num'].value + '&';
code += 'charset=' + elements['charset'].value + '&';
code += 'sitename=' + encodeURI(elements['sitename'].value);
code += '\"\>\</script\>';
elements['code'].value = code;
}
</script>
复制代码
三:生成的代码读取数据接口
复制代码
if (!empty($_GET['cat_id']))
{
$sql .= ' AND ' . get_children(intval($_GET['cat_id']));
}
if (!empty($_GET['brand_id']))
{
$sql .= " AND brand_id = '" . intval($_GET['brand_id']) . "'";
}
$output = $smarty->fetch($tpl, $cache_id);
$output = str_replace("\r", '', $output);
$output = str_replace("\n", '', $output);
echo "document.write('$output');";
复制代码
四:解析生成代码思想流程
二:生成代码界面:
复制代码
<form name="theForm" method="post" action="">
<table cellspacing="1" cellpadding="3" width="100%">
<tr>
<td class="label">{$lang.label_category}</td>
<td><select name="category" id="category">
<option value="0" selected>{$lang.all_category}</option>
{$cat_list}
</select></td>
</tr>
<tr>
<td class="label">{$lang.label_brand}</td>
<td><select name="brand" id="brand">
<option value="0" selected>{$lang.all_brand}</option>
{html_options options=$brand_list}
</select></td>
</tr>
<tr>
<td class="label">{$lang.label_intro_type}</td>
<td><select name="intro_type" id="intro_type">
<option value="all" selected>{$lang.all_intro_type}</option>
{html_options options=$intro_list}
</select></td>
</tr>
<tr>
<td class="label">{$lang.label_need_image}</td>
<td> <label>
<select name="need_image" id="need_image">
<option value="true" selected>{$lang.need}</option>
<option value="false">{$lang.need_not}</option>
</select>
</label></td>
</tr>
<tr>
<td class="label">{$lang.label_goods_num}</td>
<td><input name="goods_num" type="text" id="goods_num" value="1" /></td>
</tr>
<tr>
<td class="label">{$lang.label_arrange}</td>
<td><select name="arrange" id="arrange">
<option value="h" selected>{$lang.horizontal}</option>
<option value="v">{$lang.verticle}</option>
</select></td>
</tr>
<tr>
<td class="label">{$lang.label_rows_num}</td>
<td><input name="rows_num" type="text" id="rows_num" value="1" /></td>
</tr>
<tr>
<td class="label">{$lang.label_charset}</td>
<td><select name="charset" id="charset">
{html_options options=$lang_list}
</select></td>
</tr>
<tr>
<td class="label">{$lang.label_sitename} 1111</td>
<td><input name="sitename" type="text" id="sitename"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="button" class="button" name="gen_code" value="{$lang.generate}" onclick="genCode()" /> </td>
</tr>
<tr>
<td colspan="2" align="center"><textarea name="code" cols="80" rows="5" id="code"></textarea></td>
</tr>
</table>
</form>
复制代码
复制代码
<script language="JavaScript">
var elements = document.forms['theForm'].elements;
var url = '{$url}';
function genCode()
{
// 检查输入
if (isNaN(parseInt(elements['goods_num'].value)))
{
alert(goods_num_must_be_int);
return;
}
if (elements['goods_num'].value < 1)
{
alert(goods_num_must_over_0);
return;
}
if (isNaN(parseInt(elements['rows_num'].value)))
{
alert(rows_num_must_be_int);
return;
}
if (elements['rows_num'].value < 1)
{
alert(rows_num_must_over_0);
return;
}
// 生成代码
var code = '\<script src=\"' + url + 'goods_script.php?';
if (elements['category'].value > 0)
{
code += 'cat_id=' + elements['category'].value + '&';
}
if (elements['brand'].value > 0)
{
code += 'brand_id=' + elements['brand'].value + '&';
}
if (elements['intro_type'].value != 'all')
{
code += 'intro_type=' + elements['intro_type'].value + '&';
}
code += 'need_image=' + elements['need_image'].value + '&';
code += 'goods_num=' + elements['goods_num'].value + '&';
code += 'arrange=' + elements['arrange'].value + '&';
code += 'rows_num=' + elements['rows_num'].value + '&';
code += 'charset=' + elements['charset'].value + '&';
code += 'sitename=' + encodeURI(elements['sitename'].value);
code += '\"\>\</script\>';
elements['code'].value = code;
}
</script>
复制代码
三:生成的代码读取数据接口
复制代码
if (!empty($_GET['cat_id']))
{
$sql .= ' AND ' . get_children(intval($_GET['cat_id']));
}
if (!empty($_GET['brand_id']))
{
$sql .= " AND brand_id = '" . intval($_GET['brand_id']) . "'";
}
$output = $smarty->fetch($tpl, $cache_id);
$output = str_replace("\r", '', $output);
$output = str_replace("\n", '', $output);
echo "document.write('$output');";
复制代码
四:解析生成代码思想流程
新闻资讯 更多
热门文章
- 178Moban源码谈谈免费源码与收费源码的区别
- 2帝国CMS忘记后台登陆用户名、密码、认证码的解决方法
- 3帝国CMS(EmpireCMS) v7.5后台任意代码执行漏洞及具体修复方法
- 4帝国CMS和WordPress 哪个好?哪个适合建站?
- 5如何解决Discuz的密码错误次数过多请15分钟后登陆的问题
- 6帝国cms灵动标签取得内容和栏目链接地址
- 7emlog pro 注册码“开心”教程(如果有一天,emlog官方版 或者 emlog免费版 跑路了,那用户怎么办?)
- 8织梦CMS在nginx下设置伪静态方法(附nginx伪静态规则)
- 9帝国cms后台登录出现”您还未登录”怎么解决?
- 10帝国cms7.5忘记登录密码 和忘记登录认证码以及多次登录 失败被锁定解决办法