0
%%=[IF @country == IT then]=%% 

%%=ContentAreaByName("My Contents\3_content_test\test_HEADER\COUNTRY\IT")=%% 

Just i have removed the flower brackets just try it will work out.

I'm trying to built a Content Box using ContentAreaByName function and IF Statement, but it doesn't work. Please find below the code snippet:

%%[VAR @country
SET @country = Country
]%%


%%=[IF (@country) == IT then]=%% 
%%=ContentAreaByName("My Contents\3_content_test\test_HEADER\COUNTRY\IT")=%% 

%%=[END IF]=%%

%%=[IF (@country) == FR then]=%% 
%%=ContentAreaByName("My Contents\3_content_test\test_HEADER\COUNTRY\FR")=%% 

%%=[END IF]=%%

When I try to preview in ET I receive this error:

Unable to generate preview

A scripting error has occurred. The function call uses an unrecognized function name. Function Name: [IF Function Call: [IF (@country) == IT then]

Could you point where am I doing wrong? Thank you, Giulia

1 Answer 1

1

You're missing some quotes in your IF statements. Also, there's no space in ENDIF.

Here's how I usually do these types of conditionals:

%%[
VAR @country, @contentPath
SET @country = AttributeValue("Country") /* handles null values */

IF @country == "IT" then
  set @contentPath = "My Contents\3_content_test\test_HEADER\COUNTRY\IT"
elseif @country == "FR" then
  set @contentPath = "My Contents\3_content_test\test_HEADER\COUNTRY\FR"
else
  set @contentPath = "My Contents\3_content_test\test_HEADER\COUNTRY\DEFAULT"
endif

]%%
%%=ContentAreaByName(@contentPath)=%%

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .