Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Dec 2008
    Location
    Ireland
    Posts
    65
    Thanks
    35
    Thanked 1 Time in 1 Post

    Add image to each story in RSS feed reader

    I have an RSS feed reader that takes several different feeds, sorts the feeds using the Simplepie function, then it cache's the stories with Simplepie and displays all the news items by newest news item first. I have been trying to add a function to the rss feed reader so that each news item will display an image or logo for that feed, regardless of whether the feed has an image or not.

    So ultimately if i have 9 news stories from 3 rss feeds, each of those feeds will display an image or logo that i have stored on MY website. The reason is many websites don't bother with logo's, pictures or images in their feed and it makes the news boring to read. So i want to make the feeds more interesting to read by adding images associated with that website.

    How I'm doing this;

    I have added the code to the feed-reader.xml file so each XML feed has a URL for an image i have stored on my website like this;
    BBC news ; feed_url01 ; http://newsrss.bbc.co.uk/rss/newsonl...t_page/rss.xml

    And i also have this line for each feed;
    BBC news image ; feed_url01_img ; /images/news_images/bbc-news.png

    So that is what is stored in MySql database. I have done that for all my feeds, I'm just adding "_img" for each URL so each feed has an extra input box to add a URL for an image. these get stored in the database.

    So in the MySql database, each feed has 2 params like this;
    feed_url01=http://www.my-freed-url.com/feed.xml
    feed_url01_img=/images/news_images/bbc-news.png

    In the PHP page feed-reader.php, which displays the feeds, i have added this to get the image params;
    $feed_url01_img = $params->get('feed_url01_img','');
    $feed_url02_img = $params->get('feed_url02_img','');
    $feed_url03_img = $params->get('feed_url03_img','');

    Then lower down the page i added this to display the images;
    <!-- feed project image 1 -->
    <?php if($feed_url01_img) { ?>
    <img src="<?php echo $feed_url01_img; ?>" />
    <?php } ?>
    <!-- feed project image 2 -->
    <?php if($feed_url02_img) { ?>
    <img src="<?php echo $feed_url02_img; ?>" />
    <?php } ?>
    <!-- feed project image 3 -->
    <?php if($feed_url03_img) { ?>
    <img src="<?php echo $feed_url03_img; ?>" />

    The problem, and why its not working!!!

    So the end result here is that every single news item displays ALL the images.

    Can anyone help. What should i change so only the BBC news items will display the BBC news image and the same for each news item feed displayed.

    In the PHP page, i'm calling <?php if($feed_url01_img) { ?> but its adding the image to all the news stories, not just the BBC news story. This seems to be related to the way the cached files are stored using the Simplepie function. Somehow i need a function that will just add the image along with the selected news story.

    I would appreciate any help with this.

    Thank you,
    John.

  • #2
    Regular Coder PHP6's Avatar
    Join Date
    Aug 2008
    Location
    Czech Republic
    Posts
    239
    Thanks
    18
    Thanked 34 Times in 33 Posts
    I am really sorry but I have read your post two times and it is really difficult to say why you get this error without following information:
    1. We need the sample PHP script which generates that wrong result code
    2. We need to see the result xml file of that script to see what and where it adds images.

    p.s. To be honest I cannot understand why you are using MySQL for such simple task? You can simply use txt file to store that basic information. Even more: I cannot understand why you have blog url, blog name and blog image separated? AFAK all this three parameters are unique for any particular RSS, are not they?

  • Users who have thanked PHP6 for this post:

    John37309 (12-05-2008)

  • #3
    New Coder
    Join Date
    Dec 2008
    Location
    Ireland
    Posts
    65
    Thanks
    35
    Thanked 1 Time in 1 Post
    Quote Originally Posted by PHP6 View Post
    I am really sorry but I have read your post two times and it is really difficult to say why you get this error without following information:
    1. We need the sample PHP script which generates that wrong result code
    2. We need to see the result xml file of that script to see what and where it adds images.

    p.s. To be honest I cannot understand why you are using MySQL for such simple task? You can simply use txt file to store that basic information. Even more: I cannot understand why you have blog url, blog name and blog image separated? AFAK all this three parameters are unique for any particular RSS, are not they?
    Thanks for the reply PHP6,
    I am doing it this way because i have only have a very basic understanding of how to write this stuff. So this is an extra module that another guy wrote and it works with Joomla websites like mine. All i can do is try add this extra image feature to the mod.

    For joomla websites, this mod needs two files to work. It needs an xml file for the admin backend and the php file for the user front end

    This is the admin backend xml file for storing the params for the module in the sql database;

    PHP Code:
    <?php
    /*
    // JoomlaWorks "Simple RSS Feed Reader" Module for Joomla! 1.5.x - Version 1.4
    // License: http://www.gnu.org/copyleft/gpl.html
    // Copyright (c) 2006 - 2008 JoomlaWorks, a Komrade LLC company.
    // More info at http://www.joomlaworks.gr
    // Developers: Fotis Evangelou
    // ***Last update: May 20th, 2008***
    */

    /** ensure this file is being included by a parent file */
    defined('_JEXEC') or die('Restricted access');

    global 
    $mainframe;

    // j!1.5 paths
    $mosConfig_absolute_path JPATH_SITE;
    $mosConfig_live_site JURI :: base();
    if(
    substr($mosConfig_live_site, -1)=="/"$mosConfig_live_site substr($mosConfig_live_site0, -1);

    // module parameters
    $moduleclass_sfx     $params->get'moduleclass_sfx','');
    $srfr_cache            intval($params->get('srfr_cache',30));
    $srfr_timeout        intval($params->get('srfr_timeout',10));
    $srfr_fitems        intval($params->get('srfr_fitems',5));
    $srfr_totalitems    intval($params->get('srfr_totalitems'));
    $srfr_ftimezone        intval($params->get('srfr_ftimezone',0));
    $srfr_fname            intval($params->get('srfr_fname',1));
    $srfr_fititle        intval($params->get('srfr_fititle',1));
    $srfr_fitime        intval($params->get('srfr_fitime',1));
    $srfr_fi_content    $params->get('srfr_fi_content','none');
    $srfr_fi_words        intval($params->get('srfr_fi_words',''));
    $srfr_fi_hideimages    intval($params->get('srfr_fi_hideimages',1));
    $striptags             intval($params->get('striptags',0));

    $srfr_url01_img     $params->get('srfr_url01_img','');
    $srfr_url02_img     $params->get('srfr_url02_img','');
    $srfr_url03_img     $params->get('srfr_url03_img','');

    $srfr_url01    $params->get'srfr_url01''http://feeds.feedburner.com/joomlaworks' );
    $srfr_url02 $params->get'srfr_url02''' );
    $srfr_url03 $params->get'srfr_url03''' );
    $srfr_url04 $params->get'srfr_url04''' );
    $srfr_url05 $params->get'srfr_url05''' );
    $srfr_url06 $params->get'srfr_url06''' );
    $srfr_url07 $params->get'srfr_url07''' );
    $srfr_url08 $params->get'srfr_url08''' );
    $srfr_url09 $params->get'srfr_url09''' );
    $srfr_url10 $params->get'srfr_url10''' );
    $srfr_url11 $params->get'srfr_url11''' );
    $srfr_url12 $params->get'srfr_url12''' );
    $srfr_url13 $params->get'srfr_url13''' );
    $srfr_url14 $params->get'srfr_url14''' );
    $srfr_url15 $params->get'srfr_url15''' );
    $srfr_url16 $params->get'srfr_url16''' );
    $srfr_url17 $params->get'srfr_url17''' );
    $srfr_url18 $params->get'srfr_url18''' );
    $srfr_url19 $params->get'srfr_url19''' );
    $srfr_url20 $params->get'srfr_url20''' );


    // SimplePie Setup
    if(!class_exists("SimplePie")){
        require_once(
    $mosConfig_absolute_path.'/modules/mod_jw_srfr/mod_jw_srfr/simplepie.inc');
    }
    require_once(
    $mosConfig_absolute_path.'/modules/mod_jw_srfr/mod_jw_srfr/idn/idna_convert.class.php');

    // Call the feeds
    $myfeeds = array();
    $myfeeds[] = ''.$srfr_url01.'';
    if (
    $srfr_url02) {$myfeeds[] = ''.$srfr_url02.'';}
    if (
    $srfr_url03) {$myfeeds[] = ''.$srfr_url03.'';}
    if (
    $srfr_url04) {$myfeeds[] = ''.$srfr_url04.'';}
    if (
    $srfr_url05) {$myfeeds[] = ''.$srfr_url05.'';}
    if (
    $srfr_url06) {$myfeeds[] = ''.$srfr_url06.'';}
    if (
    $srfr_url07) {$myfeeds[] = ''.$srfr_url07.'';}
    if (
    $srfr_url08) {$myfeeds[] = ''.$srfr_url08.'';}
    if (
    $srfr_url09) {$myfeeds[] = ''.$srfr_url09.'';}
    if (
    $srfr_url10) {$myfeeds[] = ''.$srfr_url10.'';}
    if (
    $srfr_url11) {$myfeeds[] = ''.$srfr_url11.'';}
    if (
    $srfr_url12) {$myfeeds[] = ''.$srfr_url12.'';}
    if (
    $srfr_url13) {$myfeeds[] = ''.$srfr_url13.'';}
    if (
    $srfr_url14) {$myfeeds[] = ''.$srfr_url14.'';}
    if (
    $srfr_url15) {$myfeeds[] = ''.$srfr_url15.'';}
    if (
    $srfr_url16) {$myfeeds[] = ''.$srfr_url16.'';}
    if (
    $srfr_url17) {$myfeeds[] = ''.$srfr_url17.'';}
    if (
    $srfr_url18) {$myfeeds[] = ''.$srfr_url18.'';}
    if (
    $srfr_url19) {$myfeeds[] = ''.$srfr_url19.'';}
    if (
    $srfr_url20) {$myfeeds[] = ''.$srfr_url20.'';}

     
    // This array will hold the items we'll be grabbing.
    $first_items = array();
     
    // Let's go through the array, feed by feed, and store the items we want.
    foreach ($myfeeds as $url) {

        
    // Use the long syntax
        
    $feed = new SimplePie();
        
    $feed->set_feed_url($url);    
        
        
    // Set timeout
        
    $feed->set_timeout($srfr_timeout); 

        
    // Check if the cache folder exists
        
    if(file_exists($mosConfig_absolute_path.'/cache')) {
            
    $feed->enable_cache(true);
            
    $feed->set_cache_duration($srfr_cache*60);
            
    $feed->set_cache_location($mosConfig_absolute_path '/cache');
        } else {
            
    $feed->enable_cache(false);
        }

        
    $feed->init();
     
        
    // As long as we're not trying to grab more items than the feed has, go through them one by one and add them to the array.
        
    for ($x 0$x $feed->get_item_quantity($srfr_fitems); $x++) {$first_items[] = $feed->get_item($x);}
     
        
    // We're done with this feed, so let's release some memory.
        
    unset($feed);
    }
     
    // We need to sort the items by date with a user-defined sorting function.
    // Since usort() won't accept "SimplePie::sort_items", we need to wrap it in a new function.
    if(!function_exists("sort_items")){
        function 
    sort_items($a$b) {return SimplePie::sort_items($a$b);}
    }
     
    // Now we can sort $first_items with our custom sorting function.
    usort($first_items"sort_items");

    /* ----------------------- Content Handling ----------------------- */

    // Word limitation
    if (!function_exists('word_limiter')) {
        function 
    word_limiter($str$limit 100$end_char '…') {
              if (
    trim($str) == '')
                return 
    $str;
              
    preg_match('/\s*(?:\S*\s*){'. (int) $limit .'}/'$str$matches);
              if (
    strlen($matches[0]) == strlen($str))
                
    $end_char '';
              return 
    rtrim($matches[0]).$end_char;
        }
    }

    // OUTPUT
    $mod_jwsrfr_head '
    <!-- JW "Simple RSS Feed Reader" Module (v1.4) starts here -->
    <style type="text/css" media="screen">
        @import "modules/mod_jw_srfr/mod_jw_srfr/mod_jw_srfr.css";
    </style>
    <!-- JW "Simple RSS Feed Reader" Module (v1.4) ends here -->
    '
    ;
    $mainframe->addCustomHeadTag($mod_jwsrfr_head);

    ?>

    <!-- JoomlaWorks "Simple RSS Feed Reader" Module (v1.4) starts here -->
    <?php if ($feed->error){ echo '<span class="message">'.$feed->error().'</span>'; } ?>
    <div id="srfr-container<?php echo $moduleclass_sfx?>">
      <ul class="srfr">
        <?php
        
    if($srfr_totalitems) { $i=0; }
        foreach(
    $first_items as $key => $item) {
            if(
    $srfr_totalitems) {if($i>=$srfr_totalitems) continue;}
            
    $feed $item->get_feed();
        
    ?>
        <li class="srfr-row<?php echo ($key%2); ?>">
          <!-- feed name -->
          <?php if($srfr_fname) { ?>
          <a class="srfr-feed-name" target="_blank" href="<?php echo $feed->get_permalink(); ?>">
              <?php echo $feed->get_title(); ?>
          </a>&nbsp;
          <?php ?>
          <!-- feed item timestamp -->
          <?php if($srfr_fitime) { ?>
          <span class="srfr-feed-timestamp">
          <?php
            
    if($srfr_ftimezone) {
                echo 
    $item->get_date('G:i (\G\M\T) - j.m.Y'); // GMT timezone
            
    } else {
                echo 
    $item->get_date('j M Y | g:i a'); // Local timezone
            
    }
          
    ?>
          </span>
          <?php ?>
          <!-- feed project image 1 -->
          <?php if($srfr_url01) { ?>
                    <img src="<?php echo $srfr_url01_img?>" />
          <?php ?>
          <!-- feed project image 2 -->
          <?php if($srfr_url02_img) { ?>
                    <img src="<?php echo $srfr_url02_img?>" />
          <?php ?>
          <!-- feed project image 3 -->
          <?php if($srfr_url03_img) { ?>
                    <img src="<?php echo $srfr_url03_img?>" />
          <?php ?>
          <!-- feed item title -->
          <?php if($srfr_fititle) { ?>
          <a class="srfr-feed-title" target="_blank" href="<?php echo $item->get_permalink(); ?>">
              <?php echo $item->get_title(); ?>
          </a>
          <?php ?>
          <!-- feed item intro/full text -->
          <?php
            
    // Assign
            
    $introtext $item->get_description();
            
    $fulltext $item->get_content();
            
            
    // Remove images
            
    if ($srfr_fi_hideimages) {
                
    $introtext preg_replace("/<img.+?>/"""$introtext);
                
    $fulltext preg_replace("/<img.+?>/"""$fulltext);
            }        
                
            
    // HTML cleanup
            
    $allowed_tags "<img><p><br><a><b>"// These tags will NOT be stripped off!
            
    if ($striptags) {
                
    $introtext strip_tags($introtext$allowed_tags);
                
    $fulltext strip_tags($fulltext$allowed_tags);
            }
                
            
    // Word limitation
            
    if ($srfr_fi_words) {
                
    $introtext word_limiter($item->get_description(),$srfr_fi_words);
                
    $fulltext word_limiter($item->get_content(),$srfr_fi_words);
            }
          
    ?>      
          <?php if($srfr_fi_content=="intro") { ?>
          <p class="srfr-feed-intro"><?php echo $introtext?></p>
          <?php ?>
          <?php if($srfr_fi_content=="full") { ?>
          <p class="srfr-feed-full"><?php echo $fulltext?></p>
          <?php ?> 
        </li>
        <?php 
            
    if($srfr_totalitems) { $i++; }
        }
        
    ?>
      </ul>
    </div>
    <!-- JoomlaWorks "Simple RSS Feed Reader" Module (v1.4) ends here -->
    And this is the php file that users call to see the news feeds;

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <install type="module" version="1.5.0">
      <name>Simple RSS Feed Reader</name>
      <author>JoomlaWorks</author>
      <creationDate>20/05/2008</creationDate>
      <copyright>This extension in released under the GNU/GPL License - http://www.gnu.org/copyleft/gpl.html</copyright>
      <authorEmail>contact@joomlaworks.gr</authorEmail>
      <authorUrl>www.joomlaworks.gr</authorUrl>
      <version>1.4</version>
      <description>JWSRFR_DESCRIPTION</description>
      <params>
        <param name="moduleclass_sfx" type="text" default="" label="Module Class Suffix" description="A suffix to be applied to the css class of the module (table.moduletable). This allows individual module styling." />
        <param name="@spacer" type="spacer" default="" label="" description="" />
        <param name="srfr_cache" type="text" default="30" label="Cache refresh time (in minutes)" description="Set the cache refresh time (in minutes). Increasing this time maximizes the performance of your website, but RSS feeds are refreshed less often. A time between 15 to 30 minutes is the best choise. In order for the 'cache' to work, your Joomla! (or Mambo) cache folder must be server writable at least." />
        <param name="srfr_timeout" type="text" default="10" label="RSS Feed timeout" description="Set the time in seconds after which the module will timeout and stop requesting for data from problematic RSS feeds. Such feeds can come from source sites that are either sluggish or down. Choose to set a higher value if your server can sometimes be sluggish as well. Try though not to exceed 30 seconds." />
        <param name="srfr_fitems" type="text" default="5" label="Items to display per Feed" description="Set the maximum number of items that will be displayed per RSS feed." />
        <param name="srfr_totalitems" type="text" default="" label="Total items (from all Feeds)" description="Set the total number of items that will be displayed from all feeds. So, even if you have 4 feeds displaying in your website, with 10 items per feed, and you have set 'Total items (from all feeds)' to 15, then no more than the last 15 items from ALL feeds will be displayed. This is a nice option to have, when you don't want the list of feeds to span a mile high in your website!" />
        <param name="@spacer" type="spacer" default="" label="" description="" />
        <param name="srfr_fname" type="list" default="0" label="Display Feed name" description="Select whether to show each Feed's name or not. This is usually the source site's name.">
          <option value="0">No</option>
          <option value="1">Yes</option>
        </param>
        <param name="srfr_fititle" type="list" default="1" label="Display Feed Item title" description="Select whether to show the title of each Feed's item or not. This is usually the syndicated article title.">
          <option value="0">No</option>
          <option value="1">Yes</option>
        </param>
        <param name="srfr_fitime" type="list" default="1" label="Display Feed Item timestamp" description="Select whether to show the timestamp of each Feed's item or not. This is usually the publication timestamp of each syndicated article, also known as 'article creation timestamp' in CMS terms.">
          <option value="0">No</option>
          <option value="1">Yes</option>
        </param>
        <param name="srfr_ftimezone" type="radio" default="0" label="Timezone of Feed Item timestamp" description="Select if the dates will be shown in 'Local' or 'GMT' timezones. Use 'GMT' if your site has many international visitors or 'Local' if your visitors mainly come from the same country as you are. The 'Local' option uses Joomla!'s (or Mambo's) server time offset value, so make sure you've set your timezone offset correctly!">
          <option value="0">Local</option>
          <option value="1">GMT</option>
        </param>
        <param name="srfr_fi_content" type="radio" default="none" label="Choose Feed Item content" description="Select whether to show the intro content (usually the first few words of each syndicated article), the full content or nothing at all from each Feed Item.">
          <option value="intro">Intro content (description)</option>
          <option value="full">Full content</option>
          <option value="none">None</option>
        </param>
        <param name="srfr_fi_hideimages" type="radio" default="0" label="Hide images?" description="Select whether to show or hide images contained inside feeds. Useful to keep your layout safe, when big images are displayed within feeds!">
          <option value="0">No</option>
          <option value="1">Yes</option>
        </param>
        <param name="srfr_fi_proimages" type="radio" default="1" label="Display project image?" description="Display an image associated with this feed">
          <option value="0">No</option>
          <option value="1">Yes</option>
        </param>
        <param name="srfr_fi_words" type="text" default="" label="Force word limit" description="Word limitation for retrieved content. Leave it blank if you DO NOT wish to limit the number of words!" />
        <param name="striptags" type="radio" default="0" label="HTML cleanup" description="Do some HTML cleanup, especially when you limit the introtext by words or characters. This way you will not get 'unclosed' HTML tags like p (paragraph) that will cause your content to break. Use with caution! Allowed tags are: img, p, br, a, b. Adjust as necessery in the main php file of the module, at line 194.">
          <option value="0">No</option>
          <option value="1">Yes</option>
        </param>
        <param name="@spacer" type="spacer" default="" label="" description="" />
        <param name="srfr_url01" type="text" default="" size="60" label="Feed URL 1" description="Add an RSS feed URL here!" />
        <param name="srfr_url01_img" type="text" default="" size="60" label="Feed 1 image URL" description="Add an image to display with this news item" />
        <param name="srfr_url02" type="text" default="" size="60" label="Feed URL 2" description="Add an RSS feed URL here!" />
        <param name="srfr_url02_img" type="text" default="" size="60" label="Feed 2 image URL" description="Add an image to display with this news item" />
        <param name="srfr_url03" type="text" default="" size="60" label="Feed URL 3" description="Add an RSS feed URL here!" />
        <param name="srfr_url03_img" type="text" default="" size="60" label="Feed 3 image URL" description="Add an image to display with this news item" />
        <param name="srfr_url04" type="text" default="" size="60" label="Feed URL 4" description="Add an RSS feed URL here!" />
        <param name="srfr_url05" type="text" default="" size="60" label="Feed URL 5" description="Add an RSS feed URL here!" />
        <param name="srfr_url06" type="text" default="" size="60" label="Feed URL 6" description="Add an RSS feed URL here!" />
        <param name="srfr_url07" type="text" default="" size="60" label="Feed URL 7" description="Add an RSS feed URL here!" />
        <param name="srfr_url08" type="text" default="" size="60" label="Feed URL 8" description="Add an RSS feed URL here!" />
        <param name="srfr_url09" type="text" default="" size="60" label="Feed URL 9" description="Add an RSS feed URL here!" />
        <param name="srfr_url10" type="text" default="" size="60" label="Feed URL 10" description="Add an RSS feed URL here!" />
        <param name="srfr_url11" type="text" default="" size="60" label="Feed URL 11" description="Add an RSS feed URL here!" />
        <param name="srfr_url12" type="text" default="" size="60" label="Feed URL 12" description="Add an RSS feed URL here!" />
        <param name="srfr_url13" type="text" default="" size="60" label="Feed URL 13" description="Add an RSS feed URL here!" />
        <param name="srfr_url14" type="text" default="" size="60" label="Feed URL 14" description="Add an RSS feed URL here!" />
        <param name="srfr_url15" type="text" default="" size="60" label="Feed URL 15" description="Add an RSS feed URL here!" />
        <param name="srfr_url16" type="text" default="" size="60" label="Feed URL 16" description="Add an RSS feed URL here!" />
        <param name="srfr_url17" type="text" default="" size="60" label="Feed URL 17" description="Add an RSS feed URL here!" />
        <param name="srfr_url18" type="text" default="" size="60" label="Feed URL 18" description="Add an RSS feed URL here!" />
        <param name="srfr_url19" type="text" default="" size="60" label="Feed URL 19" description="Add an RSS feed URL here!" />
        <param name="srfr_url20" type="text" default="" size="60" label="Feed URL 20" description="Add an RSS feed URL here!" />
      </params>
      <files>
        <filename module="mod_jw_srfr">mod_jw_srfr.php</filename>
        <filename module="mod_jw_srfr">mod_jw_srfr/mod_jw_srfr.css</filename>
        <filename module="mod_jw_srfr">mod_jw_srfr/simplepie.inc</filename>
        <filename module="mod_jw_srfr">mod_jw_srfr/srfr_logo.png</filename>
        <filename module="mod_jw_srfr">mod_jw_srfr/idn/idna_convert.class.php</filename>
        <filename module="mod_jw_srfr">mod_jw_srfr/idn/license.txt</filename>
        <filename module="mod_jw_srfr">mod_jw_srfr/idn/npdata.ser</filename>
        <filename module="mod_jw_srfr">mod_jw_srfr/idn/readme.txt</filename>
      </files>
      <languages>
        <language tag="en-GB">language/en-GB/en-GB.mod_jw_srfr.ini</language>
      </languages>
    </install>
    There are other files with this mod but no point in posting them.

    Can you see what i need to change so each news item will display an image that have stored? I'm asking the question here because there is very little help avalable by the guys that made this mod.

    I appreciate you taking the time to help me with this!

    John.
    Last edited by John37309; 12-05-2008 at 02:20 AM.

  • #4
    Regular Coder PHP6's Avatar
    Join Date
    Aug 2008
    Location
    Czech Republic
    Posts
    239
    Thanks
    18
    Thanked 34 Times in 33 Posts
    Hello,

    First of all I am really sorry for such big delay but I had some problems with one of my project and all my free time was spent searching the bug

    Now regarding your problem: I have check your PHP script to get as much information from it as I could. I can definitely say that the problem should be obvious. I am not sure how the final RSS files will be outputted and generated but... You have added following code to that script:

    PHP Code:
          <!-- feed project image 1 -->
          <?php if($srfr_url01) { ?>
                    <img src="<?php echo $srfr_url01_img?>" />
          <?php ?>
          <!-- feed project image 2 -->
          <?php if($srfr_url02_img) { ?>
                    <img src="<?php echo $srfr_url02_img?>" />
          <?php ?>
          <!-- feed project image 3 -->
          <?php if($srfr_url03_img) { ?>
                    <img src="<?php echo $srfr_url03_img?>" />
          <?php ?>
    I am 100% sure that when the execution process will come up to this point, all three variables: $srfr_url01, $srfr_url02 and $srfr_url03 will be true. In other words they will have always non false values, since they were get from DB at the beginning of the script. So all of them will be outputed...

    I know what you wanted to do but I will translate to the human’s language what you have done. You are checking if the image's URL was successfully read from the DB and if so then you are printing it. WARNING: despite the fact which RSS feed you are generating right now.

    To solve the problem you must have only one variable $srfr_url with the rigth image and output only this one URL. To do so at the beginning of the script you have to select the right URL for that feed.

    Good luck

    p.s. all that are correct if that PHP script outputs only one RSS feed. In case it will output all RSS feeds available in DB (joined) then you have to add this correct URL selection mechanism inside that loop.

    p.p.s. it is very pity that you are not PHP developer. I always prefer to write my own scripts than to use someone's, especially if I have something particular to do. The problem with 'ready' script is that it has too many options which I do not need at my project... and that makes almost impossible to upgrade or change it.

  • Users who have thanked PHP6 for this post:

    John37309 (12-06-2008)

  • #5
    New Coder
    Join Date
    Dec 2008
    Location
    Ireland
    Posts
    65
    Thanks
    35
    Thanked 1 Time in 1 Post
    PHP6,
    I must thank you very much for taking the time to even look at this, i am very greatful for your help.

    I have taken this one step further, i have made progress and i am using a different method of trying to add an image to each news item.

    With this new peice of code, i search the name of the feed for certain words, if i find the words, then i add the image i have stored for that feed. Currently this just displays text "Match found", i need to find a way to make it display an image!

    This is the code;

    PHP Code:
    <?php $match false;$string_to_match "BBC news";$word $feed->get_title();
        {if(
    strchr($string_to_matchrtrim($word)) !== false){$match true;}}
        if(
    $match == true){echo("Match found");}?>
    So i search each news item title; $word = $feed->get_title();

    I search for the word "BBC News".

    If i find the word, it displays the words "Match found"

    How do i change this so that it displays the image instead?

    The image URL is stored here; $srfr_url01_img , as a url like this; /images/bbc-news.png

    If i get this code working, then i can just copy it 10 times for all the feeds and search for the name of the news feed.

    Help me with this bit;
    if($match == true){echo("Match found");}

    John.
    Last edited by John37309; 12-06-2008 at 08:30 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •