I'm working on a school project to get rss feeds from newspapers and get them styled in a Masonry lay-out. I can get the rss feed to convert in html with the Simplepie class but I want to give each article a column size from 1 to 5 with a counter.
This is what I get in html:
<div class="post col1 col2 col3 col4 col5 col1 col2 col3 col4 col5"> <!-- begin post -->
<h3 class="title"><a href="http://feedproxy.google.com/~r/dso-nieuws-sport/~3/zfFYeKYGagk/detail.aspx">Bergen naar halve finales play-offs basket</a></h3>
Instead I want the first article to have class "post col1", the second article "post col2" and after five articles the sixth should get "col1" again and so on..
This is my PHP code:
<?php if ($sportfeed->data): ?>
<?php $sportitems = $sportfeed->get_items(); ?>
<?php foreach($sportitems as $sportitem): ?>
<?php $enclosure = $sportitem->get_enclosure(0); ?>
<?php if ($enclosure):?>
<div class="post
<?php $teller = 1;
for ($i = 1; $i <= 10 /* aantal artikels in feed */; $i++) {
if ($teller == 1) {
echo " col1";
++$teller;
} else if ($teller ==2)
{
echo " col2";
++$teller;
} else if ($teller ==3)
{
echo " col3";
++$teller;
} else if ($teller ==4)
{
echo " col4";
++$teller;
} else
{ echo " col5";
$teller =1;
}
}?>"> <!-- begin post -->
<h3 class="title"><a href="<?php echo $sportitem->get_permalink(); ?>"><?php echo $sportitem->get_title(); ?></a></h3>
<img src ="<?php echo $enclosure->get_link(); ?> "class="img_artikel"/>
</div> <!-- einde post -->
<?php endif; ?>
<?php endforeach; ?>
Thanks a lot in advance! It would mean a lot, to get my project going.