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.

eZ debug

Timing: Jan 31 2025 05:29:11
Script start
Timing: Jan 31 2025 05:29:11
Module start 'layout'
Timing: Jan 31 2025 05:29:11
Module start 'content'
Timing: Jan 31 2025 05:29:11
Module end 'content'
Timing: Jan 31 2025 05:29:11
Script end

Main resources:

Total runtime0.0156 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 588.1328151.2109
Module start 'layout' 0.00500.0027 739.343836.6484
Module start 'content' 0.00770.0066 775.992290.2656
Module end 'content' 0.01430.0012 866.257833.9922
Script end 0.0155  900.2500 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002516.1559140.0002
Check MTime0.00117.1151140.0001
Mysql Total
Database connection0.00074.301510.0007
Mysqli_queries0.002213.862830.0007
Looping result0.00000.078110.0000
Template Total0.00095.710.0009
Template load0.00074.397910.0007
Template processing0.00021.270610.0002
Override
Cache load0.00052.934510.0005
General
dbfile0.002616.393280.0003
String conversion0.00000.055140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs