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>
Set @logo3 = Concat('http:',Field(Row(@logos,3),"Value")
should readSet @logo3 = Concat('http:',Field(Row(@logos,3),"Value"))
and you have not closed your AMPscript block with]%%
after the lastSet
. Also not sure what%%[ENDIF]%%
is actually supposed to do.