Strange switch syntax problem

Author Message

Eirik Alfstad Johansen

Wednesday 18 August 2004 6:44:03 am

Hi,

Does anyone have any clue as to why the following syntax works:

{let profile_object=fetch(content, object, hash(object_id, $profile_object_id))}
	
	{switch match=$profile_object.contentclass_id}
		{case match=23}
			
		{/case}
		{case match=24}
			{let first_name=$profile_object.data_map.first_name.content}
			{let last_name=$profile_object.data_map.last_name.content}
			{let email=$profile_object.data_map.email.content}
			{let street2=$profile_object.data_map.street_address.content}
			{let zip=$profile_object.data_map.postal_code.content}
			{let place=$profile_object.data_map.city.content}
		{/case}
		{case}
		{/case}
	{/switch}

...and the following doesn't, meaning that the rest of the content in the template is ignored (the only thing that's changed is that line #5 has been added)

{let profile_object=fetch(content, object, hash(object_id, $profile_object_id))}
	
	{switch match=$profile_object.contentclass_id}
		{case match=23}
			{let first_name=$profile_object.data_map.first_name_manager.content}
		{/case}
		{case match=24}
			{let first_name=$profile_object.data_map.first_name.content}
			{let last_name=$profile_object.data_map.last_name.content}
			{let email=$profile_object.data_map.email.content}
			{let street2=$profile_object.data_map.street_address.content}
			{let zip=$profile_object.data_map.postal_code.content}
			{let place=$profile_object.data_map.city.content}
		{/case}
		{case}
		{/case}
	{/switch}

Sincerely,

Eirik Johansen
http://www.netmaking.no/

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Ole Morten Halvorsen

Wednesday 18 August 2004 7:38:07 am

Hmm...Do you remember to close all those lets? I can easly see that as a problem. Why this work in the first case and not the second I don't know, but I would really recommend defining all your variables with let first then use set to change them.

Example:

{let first_name=false()
       profile_object=fetch( ... )
{switch ...}
{case match=24}
    {set first_name=$profile...}
{/case}
{case /}
{/switch}

{* more code * }

{/let}

Senior Software Engineer - Vision with Technology

http://www.visionwt.com
http://www.omh.cc
http://www.twitter.com/omh

eZ Certified Developer
http://ez.no/certification/verify/358441
http://ez.no/certification/verify/272578

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.