Dynamic section-specific submenu
You seem to me trying to make it more complicated as necessary. You can simply use the arg function http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/arg/7

in your example domain http://domain.example/community/communityname

arg(0) = community;

arg(1) = communityname;

so why not just use arg(0) and arg(1) in your dynamic link url