0

I have an email that is pulling the content from an XML RSS feed and placing it into a table. Specifically the AMPScript is pulling images/logos

I'd like to style the table such that there are two logos per row. In other words have Logo 1 and Logo 2 on one row and Logo 3 and Logo 4 on a second row.

As it stands now, I have all four on independent rows.

How should I be setting up my AMPScript to create a and for the first and third logos and just a for the second and fourth?

Thank you.

<table border="0" cellspacing="0" cellpadding="0">
%%[
Var @xml, @logos, @logo, @links, @link, @cnt
Set @xml = ContentAreaByName("my contents\RSSParse\LWJJobsRSSFeeds\LWJEmailTopJobsSelected")
Set @logos = BuildRowsetFromXML(@xml,"//Jobs/Job/LogoUrl", 1)
Set @links = BuildRowsetFromXML(@xml,"//Jobs/Job/DetailsUrl", 1)

If RowCount(@logos) > 4 THEN 
  Set @rows = 4 
ELSE 
  SET @rows=RowCount(@logos) 
ENDIF 

IF @rows >=1 THEN 

    for @cnt=1 to @rows do 

        Set @logo = Field(Row(@logos,@cnt),"Value")
        Set @link = Field(Row(@links,@cnt),"Value") 

]%%
        <tr>
            <td>
            <a href="%%=v(@link)=%%"><img src="%%=v(@logo)=%%"></a>
            </td>
        </tr>
%%[ 
    NEXT @cnt 
ENDIF
]%%
</table>

UPDATED:

    %%[Var @xml, @logos, @logo1, @logo2, @logo3, @logo4, @links, @link1, @link2,@link3, @link4
Set @xml = ContentAreaByName("my contents\RSSParse\LegalWeekJobsRSSFeeds\LWJEmailTopJobsSelected")
Set @logos = BuildRowsetFromXML(@xml,"//Jobs/Job/LogoUrl", 1) 
Set @links = BuildRowsetFromXML(@xml,"//Jobs/Job/DetailsUrl", 1) 
If RowCount(@logos) > 4 THEN 
Set @rows = 4 ELSE SET @rows= Divide(RowCount(@logos),2) ENDIF 
IF @rows >=1 THEN 
Set @logo1 = Concat('http:',Field(Row(@logos,1),"Value"))
Set @logo2 = Concat('http:',Field(Row(@logos,2),"Value")) 
Set @logo3 = Concat('http:',Field(Row(@logos,3),"Value")  
Set @logo4 = Concat('http:',Field(Row(@logos,4),"Value")) 
Set @link1 = Field(Row(@links,1),"Value") 
Set @link2 = Field(Row(@links,2),"Value") 
Set @link3 =Field(Row(@links,3),"Value")
Set @link4=Field(Row(@links4),"Value")                                                                                                                                                                  ]%%

<tr> 
<td id="item" style="border:5px solid #FFFFFF;"> 
 <a id="rhc-jobslist-item-1" href="%%=v(@link1)=%%" style="color:#005f9e; text-decoration:none;">
<img src="%%=v(@logo1)=%%" width="135">
</a>
</td> 
 <td id="item" style="border:5px solid #FFFFFF;"> 
<a id="rhc-jobslist-item-1" href='%%=v(@link2)=%%' style="color:#005f9e; text-decoration:none;">
  <img src="%%=v(@logo2)=%%" width="135">
</a>
</td>
</tr>
 <tr>
 <td id="item" style="border:5px solid #FFFFFF;">  
<a id="rhc-jobslist-item-1" href="%%=v(@link3)=%%" style="color:#005f9e; text-decoration:none;">
<img src="%%=v(@logo3)=%%" width="135"></a>                                                                               
</td> 
<td id="item" style="border:5px solid #FFFFFF;">
 <a id="rhc-jobslist-item-1" href="%%=v(@link4)=%%" style="color:#005f9e; text-decoration:none;"><img src="%%=v(@logo4)=%%" width="135"></a>
  </td>
   </tr>
   %%[ 
        ENDIF
        ]%%

XML:

<Jobs>
<Job>
<JobID>1167071</JobID>
<Title>Banking Litigator | 6 month assignment</Title>
<LocationDescription>Canary Wharf, London (Greater)</LocationDescription>
<SalaryDescription>Depending on experience</SalaryDescription>
<ShortDescription>
LOD are currently assisting a global banking institution with the development of their banking/commercial litigation team. As the result of a parti...
</ShortDescription>
<DetailsUrl>
http://www.legalweekjobs.com/job/1167071/banking-litigator-6-month-assignment/?TrackID=298800
</DetailsUrl>
<ApplyUrl>
http://www.legalweekjobs.com/apply/1167071/banking-litigator-6-month-assignment/?TrackID=298800
</ApplyUrl>
<LogoUrl>
//d2pri6dv7gk6ou.cloudfront.net/getasset/7f1abf6b-aaa5-4429-8622-55e305d10d3c/
</LogoUrl>
3
  • Please post a sample of your XML. Commented Aug 11, 2016 at 19:20
  • @AdamSpriggs I've actually found a workaround that seems to get the job done, though not in the prettiest way. See the update above as well as a sample of the XML. I essentially just declared a variable for each image and link. The problem I've run into now is that when I click any of the images, I receive a HTTP error 400. If you're looking at the email in send preview, all is fine but once sent, the href attributes for the <a> tags surrounding the images aren't evaluated and remain %%=v(@link1)=%% etc. Do you have any idea what is causing this lack of evaluation? Commented Aug 11, 2016 at 21:42
  • 1
    I'm not sure why your AMPscript could be working in the first place as you have syntax errors. Set @logo3 = Concat('http:',Field(Row(@logos,3),"Value") should read Set @logo3 = Concat('http:',Field(Row(@logos,3),"Value")) and you have not closed your AMPscript block with ]%% after the last Set. Also not sure what %%[ENDIF]%% is actually supposed to do. Commented Aug 12, 2016 at 4:37

1 Answer 1

2

Maybe you have not posted complete XML but that is not an issue. your AmpScript code missing one closing bracket Concat('http:',Field(Row(@logos,3),"Value") and i would suggest you to use RedirectTo AmpScript function in all your HREF tag to evaluate image click.

   %%[
Var @xml, @logos, @logo1, @logo2, @logo3, @logo4, @links, @link1, @link2,@link3, @link4
Set @xml = ContentAreaByName("my contents\RSSParse\LegalWeekJobsRSSFeeds\LWJEmailTopJobsSelected")
Set @logos = BuildRowsetFromXML(@xml,"//Jobs/Job/LogoUrl", 1) 
Set @links = BuildRowsetFromXML(@xml,"//Jobs/Job/DetailsUrl", 1) 

If RowCount(@logos) > 4 THEN 
    Set @rows = 4 
ELSE 
    SET @rows= Divide(RowCount(@logos),2) 
ENDIF 

IF @rows > 0 THEN 
    Set @logo1 = Concat('http:',Field(Row(@logos,1),"Value"))
    Set @logo2 = Concat('http:',Field(Row(@logos,2),"Value")) 
    Set @logo3 = Concat('http:',Field(Row(@logos,3),"Value"))
    Set @logo4 = Concat('http:',Field(Row(@logos,4),"Value")) 
    Set @link1 = Field(Row(@links,1),"Value") 
    Set @link2 = Field(Row(@links,2),"Value") 
    Set @link3 = Field(Row(@links,3),"Value")
    Set @link4 = Field(Row(@links4),"Value")        
]%%

<tr> 
    <td id="item" style="border:5px solid #FFFFFF;"> 
         <a id="rhc-jobslist-item-1" href="%%=RedirectTo(@link1)=%%" style="color:#005f9e; text-decoration:none;">
            <img src="%%=v(@logo1)=%%" width="135">
        </a>
    </td> 
    <td id="item" style="border:5px solid #FFFFFF;"> 
        <a id="rhc-jobslist-item-1" href='%%=RedirectTo(@link2)=%%' style="color:#005f9e; text-decoration:none;">
          <img src="%%=v(@logo2)=%%" width="135">
        </a>
    </td>
</tr>

 <tr>
    <td id="item" style="border:5px solid #FFFFFF;">  
        <a id="rhc-jobslist-item-1" href="%%=RedirectTo(@link3)=%%" style="color:#005f9e; text-decoration:none;">
            <img src="%%=v(@logo3)=%%" width="135">
        </a>                                                                               
    </td> 
    <td id="item" style="border:5px solid #FFFFFF;">
        <a id="rhc-jobslist-item-1" href="%%=RedirectTo(@link4)=%%" style="color:#005f9e; text-decoration:none;">
            <img src="%%=v(@logo4)=%%" width="135">
        </a>
    </td>
 </tr>
 %%[ENDIF]%%

You must log in to answer this question.

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