-- -- content_item__get_virtual_path/2 -- create or replace function content_item__get_virtual_path( integer, integer ) returns varchar as $$ declare get_virtual_path__item_id alias for $1; get_virtual_path__root_folder_id alias for $2; -- default content_item_globals.c_root_folder_id v_path varchar; v_item_id cr_items.item_id%TYPE; v_is_folder boolean; v_index cr_items.item_id%TYPE; begin -- first resolve the item v_item_id := content_symlink__resolve(get_virtual_path__item_id); v_is_folder := content_folder__is_folder(v_item_id); v_index := content_folder__get_index_page(v_item_id); -- if the folder has an index page if v_is_folder = 't' and v_index is not null then v_path := content_item__get_path(content_symlink__resolve(v_index),null); else v_path := content_item__get_path(v_item_id,null); end if; return v_path; -- exception -- when NO_DATA_FOUND then -- return null; end;$$ language plpgsql;