0

I want to show the content area, on checking how many records are having meetingdate greater then today. below is my code. In my code, no content areas are showing. Don't know where I went wrong.

%%[
SET @Count=0
Set @rs = LookupOrderedRows("Res_InfoMeeting_tst",5,"MeetingDate Asc","MeetingType","on") 
set @rowCount = rowcount(@rs)

if @rowCount > 0 then
    for @i = 1 to @rowCount do

        SET @row = Row(@rs,@i)
        SET @meetingDate = field(@row,"MeetingDate")
        SET @MeetingID = field(@row,"MeetingID")
        Set @MeetingURL = CONCAT('http://www.ef.pl/ils/infomeetings/v3/?infomeetingId=',@MeetingID)

        if(@meetingDate > Now()) Then
            SET @Count1=Add(@Count,1)
            if (@Count1==1)Then
            %%=ContentAreaByName("My Contents\Dynamic Content - test\ranjith_test-1")=%%<br/><br/>
            elseif(@Count1==2)Then
            %%=ContentAreaByName("My Contents\Dynamic Content - test\ranjith_test-2")=%%<br/><br/>
            elseif(@Count1==3)Then
            %%=ContentAreaByName("My Contents\Dynamic Content - test\ranjith_test-3")=%%<br/><br/>
            elseif(@Count1==4)Then
            %%=ContentAreaByName("My Contents\Dynamic Content - test\ranjith_test-4")=%%<br/><br/>
            elseif(@Count1==5)Then
            %%=ContentAreaByName("My Contents\Dynamic Content - test\ranjith_test-5")=%%<br/><br/>
            endif
        ]%%
        %%[
        endif
    next @i
else
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tbody>
            <tr>
                <td>
                    content-4
                </td>
            </tr>
        </tbody>
    </table>
endif
]%%
%%=v(@Count1)=%% 
  • You should call your first if variables before you call the else . – Samuel Dare Jul 24 '17 at 21:39
  • Count1 isn't set to a content area – Samuel Dare Jul 24 '17 at 21:40
1

You're not closing your AMPScript blocks properly. You can't output raw HTML inside the %%[ ]%% tags.

%%[

SET @Count = 0
Set @rs = LookupOrderedRows("Res_InfoMeeting_tst",5,"MeetingDate Asc","MeetingType","on") 
set @rowCount = rowcount(@rs)

if @rowCount > 0 then

    for @i = 1 to @rowCount do

        SET @row = Row(@rs,@i)

        SET @meetingDate = field(@row,"MeetingDate")
        SET @MeetingID = field(@row,"MeetingID")
        Set @MeetingURL = CONCAT('URL',@MeetingID)

        if (@meetingDate > Now()) Then

            SET @Count = Add(@Count,1)

            if (@Count == 1) Then
                 SET @showcontent = ContentAreaByName("My Contents\Dynamic Content - test\test_content-1")
            elseif (@Count == 2) Then
                  SET @showcontent = ContentAreaByName("My Contents\Dynamic Content - test\test_content-2")
            elseif (@Count == 3) Then
                  SET @showcontent = ContentAreaByName("My Contents\Dynamic Content - test\test_content-3")
            elseif (@Count == 4) Then
                  SET @showcontent = ContentAreaByName("My Contents\Dynamic Content - test\test_content-4")
            elseif (@Count == 5) Then
                   SET @showcontent =  ContentAreaByName("My Contents\Dynamic Content - test\test_content-5")
            endif

            output(treatascontent(@showcontent))

        endif

    next @i
else
]%%
<table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tbody>
        <tr>
            <td>
            content-4
            </td>
        </tr>
    </tbody>
</table>
%%[endif]%%
%%=v(@Count)=%%

The treatascontent() function will ensure any AMPScript in your content areas will be evaluated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.