当前位置: 首页>>代码示例>>PHP>>正文


PHP Category_Model::all_children方法代码示例

本文整理汇总了PHP中Category_Model::all_children方法的典型用法代码示例。如果您正苦于以下问题:PHP Category_Model::all_children方法的具体用法?PHP Category_Model::all_children怎么用?PHP Category_Model::all_children使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Category_Model的用法示例。


在下文中一共展示了Category_Model::all_children方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 function index()
 {
     /*
     // adding children //
     $id = 2;
     
     //load catagory with id 4
     $category = new Category_Model($id);
     
     //create root node (our first category)
     //$category = new Category_Model;
     //$category->name = 'category 1';
     //$category->save();
     
     $category2 = new Category_Model;
     $category2->name = 'first child of category '.$id;
     $category2->add_to($category); // not: $category3->save() !
     
     $category3 = new Category_Model;
     $category3->name = 'second child of category '.$id;
     $category3->add_to($category); // not: $category3->save() !
     
     //after each modification to the tree, we need to rebuild it
     $category_r = new Category_Model(1);
     $category_r->rebuild_tree();
     */
     // children statistic //
     $category = new Category_Model(1);
     echo $category->name;
     echo '<BR>';
     // does the category have any children?
     echo $category->has_children() ? 'Yes' : 'No';
     echo '<BR>';
     echo 'has ' . $category->count_children() . ' children<BR>';
     echo 'has ' . $category->find_related('catagories_description')->count_all() . ' catagories_description<BR>';
     //just returns all the children of the selected catagory
     $children = $category->all_children(true);
     //the param "true" means to include the parent category iteslef as well in the list
     foreach ($children as $node) {
         echo $node->name . '<BR>';
         echo 'has ' . $node->find_related('products')->count_all() . ' products<BR>';
         echo 'has ' . $node->find_related('catagories_description')->count_all() . ' catagories_description<BR>';
         /*
         foreach($node->products as $prod){
         	echo $prod->name.'<BR>';
         }
         */
         echo $node->catagories_description->description . '<BR><BR>';
     }
     /*
     // deleting nodes //
     //delete category with id 2 and all(!) of its children
     $category_d = new Category_Model(2);
     $done = $category_d->delete();
     var_dump($done);
     */
     /*
     echo '<link rel="stylesheet" type="text/css" href="http://view.jquery.com/trunk/plugins/treeview/jquery.treeview.css" />
     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
     <script type="text/javascript" src="http://view.jquery.com/trunk/plugins/treeview/jquery.treeview.js"></script>';
     
     $category = new Category_Model(1);
     //outputs the tree structure in a un-ordered html list
     echo $category->get_descendants_html();
     
     echo '	
     <script type="text/javascript">
     	$(document).ready(function()
     	{
     		$("#tree").treeview({
     			animated:"medium",
     			collapsed:true				
     		});
     	});	
     </script>';
     */
     /*
     $category = new Category_Model(1);
     
     //returns a recursive array with all the children of the selected category
     $menu = $category->to_array();
     
     echo '<pre>';
     print_r($menu);
     echo '</pre>';
     */
     /*
     // this could be used for breadcrumbs
     $category = new Category_Model(6);
     $path = $category->get_path();
     
     foreach ($path as $category){
     	echo ' > '.$category->name;
     }
     */
     /*
     // Display a list of links
     $category_t = new Category_Model(2);
     $articles = $category_t->select_list('id', 'name', '>');
      
//.........这里部分代码省略.........
开发者ID:VinceOmega,项目名称:mcb-nov-build,代码行数:101,代码来源:category.php


注:本文中的Category_Model::all_children方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。