Well for the experiment lets try this for the time being ...
rename the function template_main(){}
that you added to the Portal.template..php to function template_portal_main(){}
Then in your sources directory find the file PortalIntegration.subs.php then find the following section
// Something portal-ish, then set the new action
if (isset($file, $function))
{
add after that
$context['sub_template'] = 'portal_main';
That should fix the main template conflict and should fix the problem, but I'm entering this on the fly and have not had time to do much testing