克隆一个新项目的快捷方式

yipeiwu_com6年前PHP代码库

有没想过最土的项目如何快速复制出一个来,然后改改就成新的团购项目了?

或者说编辑一个老项目的时候想把他另存为一个新项目而不是保存,

看下图 红色部分

zuituclone

具体开发代码(非细节),如下

修改模板,加入按钮

include/template/manage_team_edit.html

<input type=”submit” value=”保存为新项目” name=”commit” id=”leader-submit” class=”formbutton” style=”margin:10px 0 0 120px;” onclick=”cloneteam()”/>

加js 处理cloneteam函数

function cloneteam()
{
document.getElementById(‘-user-form').action=”/manage/team/edit.php?clone=1″;
document.getElementById(‘-user-form').submit();
}

注意 clone=1

另外修改模板加了几处隐藏的hidden 内容,目的是为了复制老项目中的image image1 image2 字段

<!–{if $team['image']}–><span class=”hint”><input type='hidden' name=”hidden_team_image” value=”{$team['image']}”></span><!–{/if}–>

<!–{if $team['image1']}–><span class=”hint”><input type='hidden' name=”hidden_team_image1″ value=”{$team['image1']}”></span><!–{/if}–>

<!–{if $team['image2']}–><span class=”hint”><input type='hidden' name=”hidden_team_image2″ value=”{$team['image2']}”></span><!–{/if}–>

修改 manage/team/edit.php

原来代码是这样的

zuit-clone-team1

现在代码是这样的

zuit-clone-team2

相关文章

PHP系统命令函数使用分析

复制代码 代码如下:function execute($cmd) {     $res = '';    ...

php.ini中date.timezone设置详解

date.timezone设置php5默认date.timezone为utc,改为date.timezone = PRC即可解决时间相差八小时的问题,但我在php的官方文档中看了半天也没...

慎用preg_replace危险的/e修饰符(一句话后门常用)

preg_replace函数原型: mixed preg_replace ( mixed pattern, mixed replacement, mixed subject [, int...

使用dump函数,给php加断点测试

复制代码 代码如下:function dump($var, $echo=true,$label=null, $strict=true){    $label...

一个图片地址分解程序(用于PHP小偷程序)

如题,返回一个数组,可以获得图片地址的base url,相对地址,名称等,具体见下例: <? error_reporting(E_ALL ^ E_NOTICE); $...