Loading...
 
Development

Development


Category Tree

posts: 3 United States

Hey,

I started playing with TikiWiki just recently and liking what I saw. One thing I'm still looking for, though, is a more prominent way to navigate categories. In fact, I've decided, I'd like the navigation on the left to simply consist of the categories rather than the system menu. This will promote the kind of organization I want for our Intranet.

Since no one seems to have wanted this feature before, I decided to try hacking my own plugin. I've never done anything with php before, but it looked like I could mostly just copy code from tiki-browse_categories.php.

I thought I had it almost done, but it seems like I'm missing some basic concepts about how scope of variables work and stuff. The same code that works in tiki-browse_categories.php will not work when it's called from my wikiplugin_cattree function.

First I stripped most of the code from tiki-browse_categories.php, leaving just the stuff that showed the tree of categories. I saved the file (after backing it up and all) and just viewed it by clicking on "categories" in tiki. I got this working where it properly showed the tree, with expandable branches and everything, but without showing the rest of tiki.

Then I made it into a plugin like this:

function wikiplugin_cattree($data, $params) {
	require_once('tiki-setup.php');
	include_once('lib/categories/categlib.php');
	include_once('lib/tree/categ_browse_tree.php');
	
	// Check for parent category or set to 0 if not present
	if(!isset($_REQUEST["parentId"])) {
	  $_REQUEST["parentId"]=0;
	}
	
	// If the parent category is not zero get the category path
	if($_REQUEST["parentId"]) {
	  $path = $categlib->get_category_path_browse($_REQUEST["parentId"]);
	  $info = $categlib->get_category($_REQUEST["parentId"]);
	  $description = $info["description"];
	  $father = $info["parentId"];
	} else {
	  $path = tra("TOP");
	  $description = "";
	  $father = 0;
	}
	
	// Convert $childrens
	//$debugger->var_dump('$children');
	$ctall = $categlib->get_all_categories_ext(); //get_all_categories() is obsolete by now?
	$tree_nodes = array();
	foreach ($ctall as $c)
	{
	  $tree_nodes[] = array("id"=>$c["categId"],
							"parent"=>$c["parentId"],
							"data"=>''.$c["name"].'');
	
	}
	
	$tm = new CatBrowseTreeMaker("categ");
	$out = $tm->make_tree($_REQUEST["parentId"], $tree_nodes);
	return ''.$out.''; 
}


The funny thing is, all that code that worked fine by itself would not work when called as a plugin. It told me:

Notice: Undefined variable: dbTiki in C:\FoxServ\www\tiki\lib\categories\categlib.php on line 467 Invalid db object passed to CategLib constructor

Then I added These lines to the top:

global $dbTiki; include_once('db/tiki-db.php');

That fixed the error above, but now I have this message:

Fatal error: Call to a member function on a non-object in C:\FoxServ\www\tiki\categorize.php on line 24

With a little investigation, I've found that categorize.php is not called from any of the files included by my plugin. I've also found that if I generate an error on the last line of my function, the categorize.php error gets displayed after my function's error.

I'm feeling rather disoriented. I don't know if I needtroubleshooting help or if I need to be filled in on some basic principles that I'm breaking. Does anyone have any pointers?

This little feature would be a big boon to our Intranet, and it seems like it would be handy for other Tiki users as well. Thanks for taking time to decipher my post--and passing on any counsel.

Jonathan

posts: 2881 United Kingdom

Hi!

Wow! Yeah, this sounds like a good idea, something which I've kind of created by using a menu on http://damiansworld.damosoft.homelinux.net .

I'll look into the code you have when I get back home tonight and can play on a tiki installation.

I'll keep you posted on this thread, you might want to click watch, if you havent already.

- Damian

posts: 3 United States
Thank you!! Yes, I definitely have watch clicked.

posts: 3 United States
Thank you!! Yes, I definitely have watch clicked.

posts: 2881 United Kingdom

> marclaporte:
> Hi!
>
> Our category system could be enhanced with:
> http://phplayersmenu.sourceforge.net/
>
> M ;-)

Yes, cascading submenus! biggrin and phplayers options are already in 1.8/CVS code

posts: 3 United States

Hmm. Should I just get the latest CVS code to work with? Or is there a release candidate coming soon that will have that?

Of course I'm still interested in just how my code breaks the page.

Also, my next big wish for tiki would be category-based access control for pages--and also category admin rights restricted to particular branches. I don't know how complicated that would be, but it sure would be handy.

posts: 1630 Canada

> Also, my next big wish for tiki would be category-based access control for pages--and also category admin rights restricted to particular branches. I don't know how complicated that would be, but it sure would be handy.


Hi Jonathan,

This will indeed be very handy. Please come work with us in CVS.

Thanks!!

M ;-)

posts: 46 Portugal

Hi there,
Is there anyone that can provide an example on how to integrate the PHPLayers system with th Tiki Categories and Tiki Modules? (or a link to an example)

I was reading this thread but I must confess that at some point I got lost and puzzled rolleyes

Thanks for your time...

Luis Pedro


posts: 2881 United Kingdom

> marclaporte:
> Hi!
>
> Our category system could be enhanced with:
> http://phplayersmenu.sourceforge.net/
>
> M ;-)

Yes, cascading submenus! biggrin and phplayers options are already in 1.8/CVS code

posts: 3 United States

Hmm. Should I just get the latest CVS code to work with? Or is there a release candidate coming soon that will have that?

Of course I'm still interested in just how my code breaks the page.

Also, my next big wish for tiki would be category-based access control for pages--and also category admin rights restricted to particular branches. I don't know how complicated that would be, but it sure would be handy.

posts: 1630 Canada

> Also, my next big wish for tiki would be category-based access control for pages--and also category admin rights restricted to particular branches. I don't know how complicated that would be, but it sure would be handy.


Hi Jonathan,

This will indeed be very handy. Please come work with us in CVS.

Thanks!!

M ;-)

posts: 46 Portugal

Hi there,
Is there anyone that can provide an example on how to integrate the PHPLayers system with th Tiki Categories and Tiki Modules? (or a link to an example)

I was reading this thread but I must confess that at some point I got lost and puzzled rolleyes

Thanks for your time...

Luis Pedro


posts: 1 Norway

I'd like to get updated on the status of the progress on the category tree feature, as I've been thinking about implementing this kind of feature myself. But as I haven't been coding php a lot redface I would like to see what kind of functonality you've come up with.

Please post your answer here - I've toggled a watch on this thread...

prestoy

posts: 1630 Canada

There has been some work on access control for categories for Tiki 1.9

Try it out!


posts: 1630 Canada

There has been some work on access control for categories for Tiki 1.9

Try it out!


posts: 9 United States

Category Tree-based Menu


I agree, I think a module to create a menu from the category tree would be useful for many types of sites. The permission system for categories in Tiki 1.9 is fantastic. You would want to keep the same automatic filtering of the category list based upon the user's permissions.

Two other ideas:

  1. Home pages for the categories. It would be nice to send them to a Wiki particular page when they click on the category in the menu.
  2. Category sort order. People will want to independantly order the categories in the menu. Alphabetical listings will only work in limited situations.


Is there any development in this direction?
Are there particular developers that have adopted the category system?


posts: 9 United States

OK, ignor this.

The custom menu works well for creating a category-based menu. Granted, you have to manually enter each item - but our menu did not exactly match the category tree anyway.

To create workgroup-base navigation, I:

  1. Created a category for every group (this is how you organize the content)
  2. Created one group for each workgroup (organize the people)
    • also set "use group homepage"
    • created the wiki page for the group
    • assigned the group wiki page to its appropriate category
  3. Set permission on the category to allow it's group the correct access.
    • you may have to remove some permissions from the Editors and Registered groups to keep others out.
  4. Categorize your forums, pages, calendars, file galleries. Access and visibility should now be controlled by the permissions on the categories.
    • Object specific permissions, such as admin forum, attach file, etc.. will still need to be set.


Create a module using the menu and assign the module to a navigation bar.

posts: 4
Set permission on the category to allow it's group the correct access.

You can do that ?
with which one version ? razz

posts: 9 United States

Good question, made me think :-)
We are using Tiki 1.9 for production. Yes, there are some bugs. We really needed the category-based permissions to make the site work.

There are two permissions for categories:
tiki_p_view_categories
tiki_p_admin_categories

The registered users group has permissions to view categories by default; so they will be able to view all categories and their objects (forums, wiki pages, calendars, etc...). This is the default set from the admin groups page "tiki-admingroups.php".

If you assign the tiki_p_view_categories permission to a group using the admin categories page "tiki-admin_categories.php", it overrides the default group access and limits access to the group(s) you have selected.

  1. Admin categories from "tiki-admin_categories.php"
  2. Select set permissions (the key icon)
  3. Assign tiki_p_view_categories to a group(s)
  4. Now, the other groups are unable to see the catetory of use any resource assigned to it.
    • the exception is the admin group.



Upcoming Events

1)  18 Apr 2024 14:00 GMT-0000
Tiki Roundtable Meeting
2)  16 May 2024 14:00 GMT-0000
Tiki Roundtable Meeting
3)  20 Jun 2024 14:00 GMT-0000
Tiki Roundtable Meeting
4)  18 Jul 2024 14:00 GMT-0000
Tiki Roundtable Meeting
5)  15 Aug 2024 14:00 GMT-0000
Tiki Roundtable Meeting
6)  19 Sep 2024 14:00 GMT-0000
Tiki Roundtable Meeting
7) 
Tiki birthday
8)  17 Oct 2024 14:00 GMT-0000
Tiki Roundtable Meeting
9)  21 Nov 2024 14:00 GMT-0000
Tiki Roundtable Meeting
10)  19 Dec 2024 14:00 GMT-0000
Tiki Roundtable Meeting