2013-04-02 10 views
1

Я искал везде, но не нашел ответа на вопрос: как я могу использовать собственный миниатюру для каждого канала на странице с несколькими файлами? Если я упустил ответ, это будет связано с неправильными ключами поиска, за которые я извиняюсь заранее.simplepie: используйте мой собственный эскиз для каждого канала на странице с мультифидными данными

У меня есть следующий код до сих пор (что не так много):

<?php 
include_once('autoloader.php'); 
include_once('idn/idna_convert.class.php'); 

date_default_timezone_set('Europe/Amsterdam'); 
setlocale(LC_TIME, 'nld_nld'); 

$feed = new SimplePie(); 
$urls = (array(
    'http://myfeedurla.com' => 'descriptiona', 
    'http://myfeedurlb.com' => 'descriptionb', 
    'http://myfeedurlc.com' => 'descriptionc' 
    )); 
$feed->set_feed_url(array_keys($urls)); // this should get parse only the URLS 
$feed->set_cache_location('cache/'); 
$feed->init(); 

$feed->handle_content_type(); 
?> 

// As from here I'm using the standard simplepie code to show multiple feeds and order them by day 

     <?php 

     // Set up some variables we'll use. 
     $stored_date = ''; 
     $list_open = false; 

     // Go through all of the items in the feed 
     foreach ($feed->get_items() as $item) 
     { 
     // What is the date of the current feed item? 
     $item_date = $item->get_date('M jS'); 

     // Is the item's date the same as what is already stored? 
     // - Yes? Don't display it again because we've already displayed it for this date. 
     // - No? So we have something different. We should display that. 
     if ($stored_date != $item_date) 
     { 
      // If there was already a list open from a previous iteration of the loop, close it 
      if ($list_open) 
      { 
       echo '</ol>' . "\r\n"; 
      } 

      // Since they're different, let's replace the old stored date with the new one 
      $stored_date = $item_date; 

      // Display it on the page, and start a new list 
      echo '<h1>' . $item->get_local_date('%A %d %B %Y') . '</h1><hr>' . "\r\n"; 
      echo '<ol>' . "\r\n"; 

      // Let the next loop know that a list is already open, so that it will know to close it. 
      $list_open = true; 
     } 

     // Display the feed item however you want... 
     echo '<li>' . $item->get_local_date('%H:%M') . ' | <h4><a href="' . $item->get_permalink() . '">' . $item->get_title() . '</a></h4></li>' . "\r\n"; 
     } 
     ?> 

Где-то в HTML я хочу добавить «IMG ОПЗ =„“.» И т.д. И это должен относиться только к изображению по названию 'descriptiona'.png, соответственно' descriptionb'.png и т. д., за канал. Это возможно? И если да, то как?

Если я должен быть более понятным, пожалуйста, не стесняйтесь спрашивать. Заранее спасибо за помощь! С уважением,

ответ

0

Хорошо, у меня есть одно решение :) Я использую заголовок соответствующих фидов в имени файла img. Я добавил следующий код:

<img src="images/' . $item->get_feed()->get_title() . '.png" width="12" height="12" /> 

Теперь я только надеюсь, что питание не будет использовать/или что-то в их названиях ... Если кто-то есть лучший способ сделать это, например. благодаря тому, что вы можете добавить личный заголовок на канал, это было бы очень желанным.