The reason I used switch was that it's easy to check if the match variable value exists in an array (see documentation of switch statement):
{switch match=$CourseTypeID} {case in=$ListCourseTypesID}
I can't use an if-statement to compare $CourseTypeID and $ListCourseTypesID since one is an array and the other is a single value.
Section doesen't loop unless one uses loop=... in the section definition.
but you'll have to change
{if gt($ListCourseTypesID|count(),0)}
to a loop as this line
{section show=$ListCourseTypesID} makes the code loop thru $ListCourseTypesID
A section does not loop unless the "loop" parameter has been specified. Only using the "show" parameter makes it a conditional statement. The old documentation is not always right. Anyways, section has been deprecated as of 3.6 and the new control/looping structures should be used.
Trygve,
You can use an if statement instead of a switch to compare the string and the array. Your switch construct checks if a $CourseTypeID is in the $ListCourseTypesID array. This can be done in a more elegant way with an if statement:
{if $ListCourseTypesID|contains( $CourseTypeID )}
Why the switch doesn't work when inside an if-block is not clear to me without trying it. But try the if I mentioned to see if that alleviates the problem.