0
A
回答
1
你給我們的工作很少。
以下代碼可用於獲取下拉樹。你可以調整它來適應你的麪包屑的例子。
/**
* Create a tree dropdown based on the parent child relationships
*
* @param $parents Array of Category models to draw list for
* @return array listitem with populated tree.
*
* @access public
*/
public function makeDropDown($parents)
{
global $listItems;
$listItems = array();
$listItems['0'] = '== Choose a Category ==';
foreach ($parents as $parent) {
$listItems[$parent->category_id] = $parent->category_name;
$this->subDropDown($parent->categories);
}
return $listItems;
}
/**
* Create a tree dropdown based of a child
*
* @param $children Array of children models to draw list for
* @param $space String identation string
* @return array listitem with populated tree.
*
* @access private
*/
private function subDropDown($children, $space = '---')
{
global $listItems;
foreach ($children as $child) {
$listItems[$child->category_id] = $space . $child->category_name;
$this->subDropDown($child->categories, $space . '---');
}
}
相關問題
- 1. Strongloop:loopback創建嵌套結構化模型
- 2. 創建嵌套HTML結構與D3.js
- 3. 用django創建嵌套結構xml
- 4. 如何在Python中創建嵌套的數據結構?
- 5. 如何在golang中創建嵌套數據集的結構?
- 6. DynamoDB:如何創建一個嵌套JSON結構的表?
- 7. 建模嵌套JSON結構
- 8. 如何從嵌套結構
- 9. 如何從嵌套json創建結構html
- 10. 如何在CQ5字典中創建嵌套結構?
- 11. 如何從路徑(鍵數組)創建嵌套對象結構?
- 12. 如何在ios中創建嵌套字典結構?
- 13. 嵌套的輸入字段(父子結構)
- 14. 如何將值分配給嵌套結構中的主/父結構?
- 15. 嵌套數據結構,讓孩子繼承父
- 16. 如何創建嵌套TreeMaps?
- 17. 僅創建子項並選擇嵌套形式的父項?
- 18. 父窗口,子窗口的嵌套窗體和自動創建
- 19. SSIS - 如何處理嵌套集結構來構建維度表?
- 20. MarshalAs嵌套結構
- 21. 嵌套JSON結構
- 22. Ftp.MakeDirectory嵌套結構
- 23. 嵌套STL結構
- 24. Golang - 嵌套結構
- 25. 忽略numpy的數組創建中的嵌套結構
- 26. 從樹狀結構創建和填充嵌套的NSMutatbleDictionary類似於結構
- 27. 創建嵌套結構的動態自定義數組用C
- 28. 創建分層結構的嵌套函數
- 29. 創建嵌套結構,更好的方法是什麼?
- 30. 從Pandas爲組織結構圖創建嵌套的JSON
目前爲止的相關代碼? – kaiyaq