Tuesday, January 06, 2009

Get Current Page ID and Breadcrumbs in Portal 10.1.4

Hi,

I've seen a lot of people having problems getting the current pageid and siteid from portal 10.1.4, some time ago I post the PLSQL code to do this in the previous version of Portal by retrieving the parameters in the URL (how-to-get-current-page-id-in-portal), however, as Portal 10.l.4 builds the URLs different from other versions this solution does not work.

Here is a simple example using the wwpob_api_path.translate_path API I don't know how supported this solution is but it does the job.

Simply add the following code as a PLSQL item to any page, you can customized for your own needs, however, remember that PLSQL items have a limit on the number of characters you can add, if it becomes to big, simply create a store procedure or a function in the DB and call it from the Item, I created to be run as the PORTAL user, if you want to run it as a different users, you'll need grant execute access to the API and the table (if you need the breadcrumbs)

I hope it helps you..


declare
lv_names owa.vc_arr;
lv_values owa.vc_arr;
lv_out_url_format number;
lv_out_siteid number;
lv_out_pageid number;
lv_out_tabid number;
lv_out_item_container_siteid number;
lv_out_item_container_pageid number;
lv_out_selected_tabs varchar2(200);
lv_out_thingid number;
lv_out_thing_siteid number;
lv_out_is_item_stage_version boolean;
lv_out_hit_version boolean;
lv_out_smd_status PORTAl.wwpob_smd.smd_status_record;
lv_out_url_version varchar2(200);
lv_siteid NUMBER;
lv_pageid NUMBER;
lv_path varchar2(300);
lv_bc varchar2(1000);
begin

/****Get Current Page Path****/
lv_path:=owa_util.get_cgi_env('PATH_INFO');
lv_path:=substr(lv_path, instr(lv_path, '/',2) );
htp.p('<br>Current Path= '||lv_path);

/****Get Page and Site ID****/
portal.wwpob_api_path.translate_path
(lv_path,lv_names,lv_values,lv_out_url_format,lv_siteid,lv_pageid,lv_out_tabid,
lv_out_item_container_siteid,lv_out_item_container_pageid,lv_out_selected_tabs,lv_out_thingid,
lv_out_thing_siteid,lv_out_is_item_stage_version,lv_out_hit_version,lv_out_smd_status,lv_out_url_version);

htp.p('<br>Page Id = '||lv_pageid);
htp.p('<br>Site Id = '||lv_siteid);

/**********Breadcrumb*********/
lv_bc:='</nobr>';
for lv_rec in (SELECT B.name,B.id,
(select '/portal/page/portal'||SYS_CONNECT_BY_PATH (A.name,'/') url from portal.WWSBR_ALL_FOLDERS A WHERE A.caid = b.caid and A.id=b.id START WITH A.id = 1 CONNECT BY PRIOR A.id=A.parent_id AND PRIOR caid = A.caid) url
FROM portal.WWSBR_ALL_FOLDERS B
WHERE caid = lv_siteid
START WITH id = lv_pageid
CONNECT BY PRIOR B.parent_id=B.id AND PRIOR caid = B.caid) loop

lv_bc:=' / <a href="'||lv_rec.url||'">'||lv_rec.name||'</a>'||lv_bc;
end loop;
lv_bc:='<nobr>'||lv_bc;

htp.p('<br>Breadcrumb = '||lv_bc);

end;

2 comments:

Pedro Barreira said...

my solution to get pageid from orcale portat is in this OTN post:
http://forums.oracle.com/forums/thread.jspa?threadID=882252&tstart=0

Homer said...

Hi Pedro,

Thanks for the comment, your solution works nicely, and could be used for portal before 10.1.4, the problem with 10.1.4 is that the URL of the page no longer contains the _pageid parameter. Oracle should provide an API for this, hopefully it will be included as part of the 11g release.

Regards,
Juan