Skip to content

Instantly share code, notes, and snippets.

@joanhey
Last active January 28, 2016 16:03
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joanhey/accfd70762288977967c to your computer and use it in GitHub Desktop.
Save joanhey/accfd70762288977967c to your computer and use it in GitHub Desktop.
Kumbia Partial: show feed

Uso en el view o template

<?php View::partial('feed', '+3 hours', array('name'=>'Blog KumbiaPHP', 'url'=>'http://www.kumbiaphp.com/blog/feed/'),'feeds')?>

Partial: feed

Cache : +3 hours (o +1 day, +1 week, ... )

array con nombre y url del feed

Grupo de cache: feeds (por si quieren borrar la cache o usar otros nombres si se usa más de una vez)

<?php
/**
* Visualizar feed RSS por Joanhey
*
* @param string $name Nombre
* @param string $url URL completa del feed
* @return html
*/
if ($feed = simplexml_load_file($url)): ?>
<div class="feed">
<h3><a href="<?= h($feed->channel->link)?>" title="<?= h($feed->channel->description)?>"><?= $name?></a></h3>
<ul>
<?php foreach ($feed->channel->item as $item) : ?>
<li><a href="<?= h($item->link)?>" title="<?= h(substr(strip_tags($item->description),0,200))?>..."><?= h($item->title)?></a></li>
<?php endforeach?>
</ul></div>
<?php endif?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment