克隆一個新項目的快捷方式
有沒想過最土的項目如何快速復制出一個來,然后改改就成新的團購項目了?
或者說編輯一個老項目的時候想把他另存為一個新項目而不是保存,
看下圖 紅色部分

具體開發(fā)代碼(非細節(jié)),如下
修改模板,加入按鈕
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函數(shù)
function cloneteam()
{
document.getElementById(‘-user-form').action=”/manage/team/edit.php?clone=1″;
document.getElementById(‘-user-form').submit();
}
注意 clone=1
另外修改模板加了幾處隱藏的hidden 內(nèi)容,目的是為了復制老項目中的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
原來代碼是這樣的

現(xiàn)在代碼是這樣的

相關(guān)文章
PHP對象轉(zhuǎn)換為數(shù)組函數(shù)(遞歸方法)
本方法主要是應(yīng)用于迭代對象。我應(yīng)用的地方是simplexml中的simplexml_load_string()上,因為返回的全是對象,如果提取數(shù)據(jù)比較麻煩,所以應(yīng)用了下面的函數(shù)2012-02-02

