Get XOOPS XOOPSXOOPS FAQFAQ ForumsForums NewsNews ThemesThemes ModulesModules
New Posts New Topics All Posts All Forums Index General Modules Themes Development International XOOPS.org

Search

Donat-O-Meter

Make donations with PayPal!
Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $65.00
Net Balance: $61.80
Left to go: $38.20

Donations
studioC  ($25)May-17
Anonymous ($15)May-16
Anonymous ($25)May-4

Learn XOOPS Core

Local Support

Advertisement

XOOPS Code hosted on SourceForge

Cumulus Tag Cloud

2 2.5 2.6 3.0 2013 Abuse AntiHarvesting AntiMalUser AntiSpam API Attack Balancing Banning Beats billige black block Blocking Blocks blue Captcha cell Christmas chronolabs Cloud content Conversion dating demo docek download Dresses editor evden eve facebook familia floor free Friendica herre Honeypot Human instant-zero inStyler Invoice IP IPLog jQuery JSON kantor lamps List log logger mobile module modules Monster MyAlbum-p newbb news online Outlet PageRank Permissions pink Plugin Plus pollos portal Prevention profile project Protector publisher REST Rights rmcommon Room sale security Server site Smarty Spam stem Studio svn tag tags tdmcreate Theme themes userlog website Whitepaper xoops Xortify ZendFramework

New Users

Registering user

# 136023

qinxian123

Welcome to XOOPS!




Bottom   Previous Topic   Next Topic  Register To Post



#1 Posted on: 2009/9/1 15:07 how to use xoopstree for creating categories and subcategoires
I am looking for a guidline or tutorial to use category system in a module. but wondering if anyone can help me how can i use xoopstree for creating categories and subcategoires?

Top

Mazar
Not too shy to talk
Not too shy to talk
Joined:
2009/1/3 18:27
Group:
Registered Users
Designer Group
Posts: 176
(Show More) (Show Less)


#2 Posted on: 2009/9/1 15:26 Re: how to use xoopstree for creating categories and subcategoires
hello I am just beginning with the development but you can look at my xsitemap module maybe can help you.

Top

urbanspacema
Quite a regular
Quite a regular
Joined:
2004/9/19 15:25
From Italy
Group:
Registered Users
Posts: 265
(Show More) (Show Less)


#3 Posted on: 2009/9/1 20:21 Re: how to use xoopstree for creating categories and subcategoires
I decided I wanted to use XoopsTree class for providing categories in Video Tube. The problem I found was debug generated warning that XoopsTree class had been deprecated and XoopsObjectTree should be used instead. I am sure there were good reasons for this but I found XoopsTree very easy to understand and implement so I made a copy of the class, renamed it VideoTubeTree and added it as part of the Video Tube module.

There are five components involved to add categories and subcategories to your module.
1. The class file (in my case /modules/videotube/class/videotubetree.php)
2. MySQL database table containing category data
3. Logic in index.php file to extract category data from table and place in template variables
4. Code in template file to display the category data
5. Code in admin/index.php to administer category data

I hope you find the code helpful. Be sure to download VideoTube v1.85 to explore the code.

Top

tank1955
Module Developer
Module Developer
Joined:
2007/9/7 11:01
From Illinois
Group:
Registered Users
Posts: 171
(Show More) (Show Less)


#4 Posted on: 2009/9/2 3:15 Re: how to use xoopstree for creating categories and subcategoires
Thanks i had a look at videotube 8. But i am still digging out how to use xoopsObject tree. I think XOOPS object tree is better less coding.
I am trying to learn but the same time want to follow XOOPS standard.

Top

Mazar
Not too shy to talk
Not too shy to talk
Joined:
2009/1/3 18:27
Group:
Registered Users
Designer Group
Posts: 176
(Show More) (Show Less)


#5 Posted on: 2009/9/2 5:03 Re: how to use xoopstree for creating categories and subcategoires
If you want to use XoopsObjectTree you need to get data from a database as objects at the beginning. For this purpose, creating a class object, for example Category, into file /modules/mymodule/class/category.php
For more detail: http://www.xoops.org/modules/newbb/vi ... =&topic_id=68782&forum=28
(in the example below, my module is called pfxfp, you have to rename it to yours modulename!)
class pfxfpCategory extends XoopsObject
{
    
/**
     * constructor
     */
    
function pfxfpCategory()
    {
        
$this->__construct();
    }
    
    function 
__construct()
    {
        
//definitions of the table field names (which includes categories) from the database 
        
$this->initVar("id_cat"XOBJ_DTYPE_INTnullfalse);
        
$this->initVar("id_parent_cat"XOBJ_DTYPE_INTnullfalse);
        
$this->initVar('name'XOBJ_DTYPE_TXTBOXnullfalse255);
    }
}

class 
pfxfpCategoryHandler extends XoopsPersistableObjectHandler
{
    function 
pfxfbCategoryHandler(&$db)
    {
        
$this->__construct($db);
    }
    
    function 
__construct(&$db)
    {
        
parent::__construct($db'pfxfp_categories''pfxfpCategory''id_cat');
    }

    function 
getCategories($criteria=null)
    {
        if (!
is_object($criteria)) {
          
$criteria = new Criteria(null);
          
$criteria->setSort('name');
          
$criteria->setOrder('ASC');
        }
        
$ret $this->getObjects($criteria);
        return 
$ret;
    }
}

and call in a script
//initialize category class (modulename is importat!)
$obj_handler =& xoops_getModuleHandler('category''pfxfp');
//get data as objects
$objs $obj_handler->getCategories();
//transmitting data to XoopsObjectTree, the parameters ('id_cat', 'id_parent_cat') are the same as the class category
$kt = new XoopsObjectTree$objs'id_cat''id_parent_cat' );


If you want form with select categories
include_once XOOPS_ROOT_PATH."/class/xoopsformloader.php";
$cform = new XoopsThemeForm("form title""frm");
    
$cform->setExtra('enctype="multipart/form-data"');
    
//$kt refers to XoopsObjectTree
  
$a $kt->makeSelBox"id_parent_cat""name"'-- ' ''true );
  
$cform -> addElement( new XoopsFormLabel'Categories'$a ), true );
  
$cform->display();


Top

bumciach
Not too shy to talk
Not too shy to talk
Joined:
2007/6/25 6:14
Group:
Registered Users
Posts: 146
(Show More) (Show Less)


#6 Posted on: 2009/9/2 5:20 Re: how to use xoopstree for creating categories and subcategoires
Thanks for the easy explaination. will try that.

Top

Mazar
Not too shy to talk
Not too shy to talk
Joined:
2009/1/3 18:27
Group:
Registered Users
Designer Group
Posts: 176
(Show More) (Show Less)







You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You can vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.

[Advanced Search]