Monday 30 January 2006 9:04:03 am
The switch statement in the following code doesen't seem to be able to read the declared variables:
{def $ListCourseTypesID=array()}
{def $ListCourses=array()}
{ ... building arrays ...}
{if gt($ListCourseTypesID|count(),0)}
{foreach $ListCourses as $course}
{set CourseTypeID= ... something ...}
--> {$ListCourseTypesID.0} and {$CourseTypeID} are equal here <--
{switch match=$CourseTypeID}
{case in=$ListCourseTypesID}
-->Never enters here <--
{node_view_gui view=listitem content_node=$course}
{/case}
{/switch}
{/foreach}
{/if}
However, if I change the surrounding if to a section statement, it works
{section show=$ListCourseTypesID}
{foreach $ListCourses as $course}
{set CourseTypeID= ... something ...}
--> {$ListCourseTypesID.0} and {$CourseTypeID} are equal here <--
{switch match=$CourseTypeID}
{case in=$ListCourseTypesID}
-->Enters here, as expected <--
{node_view_gui view=listitem content_node=$course}
{/case}
{/switch}
{/foreach}
{/section}
I also tried to use a simpler case statement:
{case in=$ListCourseTypesID.0}
which didn't make any difference. Tried also to use $: in the variable references. That didn't help either. This seems to be a bug? The documentation on the switch statement doesen't mention any dependency between switch and section. Looks like switch operates in a different namespace, although I haven't specified any. I'm running ez version 3.6.2 on Linux.
|