When working with the PAGE_CONTAINER template, you can pass variables from the view templates (category_view, forum_view,thread_view, etc.) using xen:container. The same applies to any templates which are included in the PAGE_CONTAINER template; theheader or ad_header templates for example.
To use the $forum.node_id variable for example, you would add this to the PAGE_CONTAINER template: <xen:container var="$forumId">{$forum.node_id}</xen:container>.
Similarly for the $threadId variable, you would add this: <xen:container var="$threadId">{$thread.thread_id}</xen:container>.