Forum OpenACS Development: Ajax Drop Down Menues for XoWIKI

Collapse
Posted by Malte Sussdorff on
Has anyone written a template for XoWIKI which uses AJAX with drop down menus in a Navigation Bar (left to right), so you have the top level of navigation displayed all the time and then have drop down menus for the lower levels / pages?

It would make most sense in categories mode, I think. Thanks in advance for letting me know before I dig down that road myself

Collapse
Posted by Malte Sussdorff on
And while I am at it, here comes a second question. If I have a template which uses categories to display the structure, will this be able to sort the pages within a category by the section?

If I look at openacs.org/wiki, I am unable to determine in which order the pages should appear in the left navigation tree and I was wondering if there is a way to make this in a way which allows me to define, in what order they should appear.

Collapse
Posted by Torben Brosten on
Malte,
I believe pages can be sorted by Section when using Xowiki book view. For example, note how Section 6.7 appears before 6.8 on https://openacs.org/test-doc/maintenance-web (xowiki version 0.116). Early versions appear to sort alphabetically by Page Title within a category. For example, "II.1 Structure / Mechanical" should appear before "II.2 Pod name" on http://lotusgreendatacenters.com/forge/xowiki/structure-mechanical (xowiki 0.60.3)
Collapse
Posted by Malte Sussdorff on
Hi Torben, I am aware it works in Book Mode, the question here was more if it was going to work in Categories mode as well, which did not seem to be the case but maybe I am wrong here. Going for book mode only would also be an option, though categories make more sense for the application I am looking for and I would love to only use e.g. 3 or 4 Pages as "teasers" and then sort the rest alphabetically afterwards. Though I am pretty sure noone has written that one yet 😊.
Collapse
Posted by Alvaro Rodriguez on
Malte,

Something like this was done in the Content package, it is based on xowiki using categories and page_order (Section) field, this way you can sort the pages inside a category. The navigation menu uses YUI Treeview.

I'm not sure if this is what you're looking for but perhaps you'd like to check it out.
Collapse
Posted by Malte Sussdorff on
Hey Alvaro, this sounds interesting, is there a demo where I can take a look? Even if it does not help with the Menus it might be helpful for content generation...

To demonstrate what I want, take a look at http://developer.yahoo.com/yui/examples/menu/topnavfrommarkup_source.html

Communication, Shopping, Entertainment and Information are "TOP Level" Categories, PIM Is a subcategory of Communication and the rest are pages, which I can order by e.g. the page section.

Collapse
Posted by Alvaro Rodriguez on
Right, the menu is different, this is content look, for the content generation I used the categories widget in the form, and then manage the pages using the page section.

Hope this helps,
Collapse
Posted by Gustaf Neumann on
The categories includelet has a "order_items_by" attribute, which has as default value "title,asc". This means, if multiple entries are sorted by the title. You can use there as well e.g. the page_order to determine the sort order.

I think that should do what you want, or did i miss something?

Collapse
Posted by Malte Sussdorff on
This order_items_by brings me on the right track, now I need to rewrite the categories includelet render function to use ah::yui::menu_from_list or a new helper procedure if it does not provide me the wished for drop down menu. Sadly you are not using ah:: procedures to render the includelet so I need to figure that part out on my own.

As I need to change the CatTree render instproc, I would probably just generate a new class, e.g. CatMenu and add a parameter "style" or "tree_class" to ::xowiki::IncludeletClass, which defaults to "CatTree", but could also be "CatMenu", basically define the class used for the rendering. Would this be the best approach ?

Collapse
Posted by Gustaf Neumann on
The best approach is to look at the code first. You will notice that the category tree has already two styles. For adding a third one, you should define a mixin class like it is done for the section style. You will most probably loose some functionality of the includelet (like e.g. opening the tree partially the show the current item).
Collapse
Posted by Malte Sussdorff on
Well, if you define an "if {$tree_style}" as the best approach then I wholeheartedly agree with you, that looking at the code would have been sufficient 😊. Okay, enough of the underhanded compliments.

You are using a boolean to differentiate between two styles and if the "other" style is true, you mixin the Categoriy::section_style. Now, if I am using the mixin approach, I still need a way to tell the categories includelet WHICH style to mixin. As you have been using a boolean, I can hardly suggest to change the "tree_style" into a string, as this would not be backwards compatible.

Luckily, the open_item parameter for add_to_category provides me with the currently open item, allowing me to render the top navigation's menu item in a different color, if the currently displayed page is in that navigation. In past projects users solved this issue by having an include (as in XoWIKI include of another XoWIKI page) for the main navigation (without drop down menues, left to right, on top of the page), which I deem not ideal, but it worked for them 😊.

Therefore the question: How can I define the mixin class to use in the categories includelet, which is the approach you would take (as I don't want to duplicate the code for the categories includelet just to be able to call a different rendering mixin class) ?

Collapse
Posted by Gustaf Neumann on
Hi Malte,

the old interface was just for activating tree style (actually an mktree-based tree-style) and the "sections" style. The classical approach in such situation is to define a subclass, which has a more flexible interface but inherits the rest of the code.

Since there is not much code involved, i have updated the interface in cvs HEAD such one can use arbitrary category renderers. One can now define an arbitrary renderer (named ::xowiki::CategoryRenderer=$style) and pass the -style to the includelet. You can define the renderer in an arbitrary -procs file. Let me know, when you need more....

-gustaf neumann

PS: glad to see you back, i thought, we lost you to SAP.

Collapse
Posted by Gustaf Neumann on
A small followup: in order to develop a new viewer for e.g. categories, i would recommend to disable for the development the includelet caching (set parameter "cacheable" of the includelet "categories" to false). Otherwise you have to flush the page fragment cache entries frequently to check the results of your changes.
Collapse
Posted by Malte Sussdorff on
Thanks a lot for the help, I will dig my heels into this today. And good point with the caching, I would certainly have had trouble with that.

As for the loosing part, my website still runs ]project-open[ and some other sites run .LRN, so I'm not gone, just a more passive follower with the occasional odd need. Though I have to admit, the SAP world is more profitable and the Drupal world provides much easier access to developers.

Collapse
Posted by Michael Steigman on
We are working on a category browser. Initially, it'd just be for wiki but eventually the idea would be to use it under any package utilizing categories. I also want to build in the ability to manage categories if the user has permission. It probably won't look like what you've described though.

Regarding sorting of pages (categorized objects), this looks to be done alphabetically for each subcategory. I haven't checked the code, though. There is nothing in the data model to assist with that - category_object_map only stores the category_id and object_id - and that's probably how it should be. What's wrong with alphabetical display of wiki pages in each category?

Collapse
Posted by Malte Sussdorff on
The main idea for me is to use XoWIKI as a CMS light. That's why the alphabetical ordering does not help, as you might want to teaser certain pages, having them show up first in the drop down. Also, there should be a "first" page to display, if you select a category and not the subcategory, meaning, if you have a page under the main category ".LRN", then this page should show up, even though there might be more categories like ".LRN & LAMS" or "Assessment".