select category_id
from categories
where tree_id = :tree_id
and category_id in ([join $category_ids ,])
order by left_ind desc
select count(ci.item_id)
from category_object_map c, cr_items ci,
cr_revisions r, xowiki_page p
where c.object_id = ci.item_id
and ci.parent_id = :wiki_folder_id
and ci.content_type not in ('::xowiki::PageTemplate')
and ci.name not in ('es:header_page','es:index','es:indexe')
and r.revision_id = ci.live_revision
and p.page_id = r.revision_id
and c.category_id = :cat_id
group by category_id
order by category_id desc
select ci.item_id, p.page_order, ci.name, ci.content_type, category_id, xpi.page_instance_id
from category_object_map c, cr_items ci, xowiki_page p, xowiki_page_instance xpi
where c.object_id = ci.item_id and ci.parent_id = :wiki_folder_id
and ci.content_type not in ('::xowiki::PageTemplate')
and ci.name not in ('es:header_page','es:index','es:indexe')
and p.page_id = xpi.page_instance_id
and category_id in ([join $cat_id ","])
and xpi.page_instance_id = ci.live_revision
order by p.page_order