foxhound |
|
---|---|
I am trying to figure out a way to ouput all categories in the list section of my website. <img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
|
Macik |
|
---|---|
Here it is: function catlist($tpl = 'catlist', $items = 0, $order = '', $cat = '', $sub = true) { // Specific cat $cats = cot_structure_children('page', $cat, (bool)$sub,false); $t = new XTemplate(cot_tplfile($tpl, 'plug')); $totalitems = sizeof($cats); if (!$order) shuffle($cats); if ($items) { $cats = array_slice($cats,0,$items); } foreach ($cats as $idx => $cat_name) { $t->assign('CAT',$structure['page'][$cat_name]); $t->assign('cat_name',$cat_name); $t->parse('MAIN.CAT_ROW'); } $t->parse(); return $t->text(); } I use this function for my own. It similar to pagelist but more simplier. You can add it to `global` hook — for example simply add it to `pagelist.global.php` file.
https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F |
foxhound |
|
---|---|
Thanks for that!!
<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
|
Macik |
|
---|---|
First of all — I forget to add global $structure; in the beginning of function. Than you can use CAT tpl variable like: CAT.path
https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F |
foxhound |
|
---|---|
Thanks again! That sure gave me a lot more options. :)
<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
|
Macik |
|
---|---|
Not clearly understand what you speak about… Trying to answer anyway. You had one `catlist.tpl` tpl placed in `themes/plugins`. (see it below). Than you put TPL callback in your dropdown menu code (in `header.tpl` or wherever it had been placed): {PHP|catlist('catlist',0,'','root_category_name')} or {CAT_NAME|catlist('catlist',0,'','$this')} catlist,tpl: <!-- BEGIN: MAIN --> <div class="dropdown"> <ul class="dropdown-menu custom" role="menu" aria-labelledby="dropdownMenu_{CAT_TITLE}"> <!-- BEGIN: CAT_ROW --> <li class="subitem" role="presentation"><a role="menuitem" tabindex="-1" href="{cat_name|cot_url('page','c=$this')}">{CAT.title} </a></li> <!-- END: CAT_ROW --> </ul> </div> <!-- END: MAIN -->
https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F |
foxhound |
|
---|---|
Yes, that is what I am trying but it always output all categoeires and subcategories in my menu. It does not show the subcategoeries on hover, it just adds them like a normal category. <!-- BEGIN: MAIN --> <div id="navigation" class="navigation"> <ul> <!-- BEGIN: CAT_ROW --> <li><a href="index.php?e=page&c={CAT_NAME}">{CAT_NAME}</a> <ul class="sub-menu"> <li><a href="index.php?e=page&c={CAT_NAME}">{CAT_NAME}</a></li> </ul> </li> <!-- END: CAT_ROW --> </ul> </div> <!-- END: MAIN -->
But what it does is just create a dropdown for every item in the category and the dropdown will be the item itself. One big mess. <img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
|
Macik |
|
---|---|
With this simple function (`catlist`) you can not build complete category tree structure as it prints plain list of categories. So there are 3 ways to solve that:
https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F |
foxhound |
|
---|---|
Okay, thanks for all your help. :) <img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
|