Occassionally I find that I need to have a branch in template file so that some pages display with a slight variation of the template. I rely on an if/then/else or switch/case construct.
The key PHP code is add the following at the start of your template:
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$temp = JRequest::getString('id');
$temp = explode(':', $temp);
$menu = JSite::getMenu();
$alias = $menu->getActive()->alias;
if ($option == 'com_content' && $view == 'category' && $temp[0])
{
$category_id = $temp[0]; //this is category ID
}
Then later you can use the following to detect all artlcle links that aren't in selected categories for example.
if($category_id !='10' && $category_id !='11' && $category_id !='12' && $category_id !='13' && $category_id !='14') : ?>