Adding the Component Category Tree
Joris Ceelen
New Member
Posts: 9
9 năm 2 tháng trước - 9 năm 2 tháng trước #998
bởi Joris Ceelen
Adding the Component Category Tree was created by Joris Ceelen
Hi
I find myself using the following two classes a lot, unfortunately Component Creator does not set them up automatically when adding a Joomla Category field to your components table, but then it is easy.
api.joomla.org/cms-3/classes/JCategoryNode.html
api.joomla.org/cms-3/classes/JCategories.html
I like these functions and the way you can navigate the category tree
how to enable this ? ( it would be great if Component Creator would generate this file too!)
Create a file category.php in the front end under
JPATH_COMPONENT/helpers/...
here is an example of my file in
components/com_form_nutrition_fact_groups/helpers/category.php,
I think it speaks for itselfthanks!!
I find myself using the following two classes a lot, unfortunately Component Creator does not set them up automatically when adding a Joomla Category field to your components table, but then it is easy.
api.joomla.org/cms-3/classes/JCategoryNode.html
api.joomla.org/cms-3/classes/JCategories.html
I like these functions and the way you can navigate the category tree
$cats=JCategories::getInstance('Form_nutrition_fact_groups');
$cat=$cats->get($catid);
$params=$cat->getParams();
how to enable this ? ( it would be great if Component Creator would generate this file too!)
Create a file category.php in the front end under
JPATH_COMPONENT/helpers/...
here is an example of my file in
components/com_form_nutrition_fact_groups/helpers/category.php,
I think it speaks for itself
<?php
/**
* @package Joomla.Site
* @subpackage com_content
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Content Component Category Tree
*
* @since 1.6
*/
class Form_nutrition_fact_groupsCategories extends JCategories
{
/**
* Class constructor
*
* @param array $options Array of options
*
* @since 11.1
*/
public function __construct($options = array())
{
$options['table'] = '#__form_nutrition_fact_groups` ';
$options['extension'] = 'com_form_nutrition_fact_groups';
$options['field'] = 'nutrition_fact_cat_id';
parent::__construct($options);
}
}
Last edit: 9 năm 2 tháng trước by Joris Ceelen.
Vui lòng Đăng nhập hoặc Tạo tài khoản để tham gia cuộc hội thoại.
Thời gian tải trang: 0.049 giây