- Posts: 11
COMMUNITY FORUM
- Forum
- Free Joomla Extensions & Templates
- Simple RSS Feed Reader
- Extra feature: Include image beside each feed news item
Extra feature: Include image beside each feed news item
- John37309
- Topic Author
- Offline
- New Member
Less
More
15 years 11 months ago - 15 years 11 months ago #19239
by John37309
Extra feature: Include image beside each feed news item was created by John37309
I have been trying to add the function to this Simple 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 mod_jw_srfr.xml file so each XML feed has a URL for an image i have stored on my website like this;
BBC news ; srfr_url01 ; newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml
But i have added this extra line for each feed;
BBC news image ; srfr_url01_img ; /images/M_images/bbc-news.png
Looks like this in the admin panel;
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.
In the PHP page mod_jw_srfr.php, i have added this to get the image params;
$srfr_url01_img = $params->get('srfr_url01_img','');
$srfr_url02_img = $params->get('srfr_url02_img','');
$srfr_url03_img = $params->get('srfr_url03_img','');
Then lower down the page i added this to display the images;
<!-- feed project image 1 -->
<?php if($srfr_url01_img) { ?>
<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; ?>" />
The problem, why won't it work!!!
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 displayed.
In the PHP page, i'm calling <?php if($srfr_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.
If i get this working and someone helps me get this code right, we could improve this module and make it an extra feature.
Thanks,
John.
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 mod_jw_srfr.xml file so each XML feed has a URL for an image i have stored on my website like this;
BBC news ; srfr_url01 ; newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml
But i have added this extra line for each feed;
BBC news image ; srfr_url01_img ; /images/M_images/bbc-news.png
Looks like this in the admin panel;
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.
In the PHP page mod_jw_srfr.php, i have added this to get the image params;
$srfr_url01_img = $params->get('srfr_url01_img','');
$srfr_url02_img = $params->get('srfr_url02_img','');
$srfr_url03_img = $params->get('srfr_url03_img','');
Then lower down the page i added this to display the images;
<!-- feed project image 1 -->
<?php if($srfr_url01_img) { ?>
<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; ?>" />
The problem, why won't it work!!!
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 displayed.
In the PHP page, i'm calling <?php if($srfr_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.
If i get this working and someone helps me get this code right, we could improve this module and make it an extra feature.
Thanks,
John.
Please Log in or Create an account to join the conversation.
- ruigato
- Offline
- New Member
Less
More
- Posts: 18
15 years 1 month ago #19240
by ruigato
Replied by ruigato on topic Re: Extra feature: Include image beside each feed news item
did you manage to det this to work?
Please Log in or Create an account to join the conversation.
- John37309
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
15 years 1 month ago - 15 years 1 month ago #19241
by John37309
Replied by John37309 on topic Re: Extra feature: Include image beside each feed news item
ruigato,
Yes, i got this to work perfectly, take a look; www.unitedboinc.com/en/project-news
The only problem is that i ended up re-writing the vast majority of the code to make the simple feed reader work the way i wanted it too. So now the code i have is vastly different to the simple feed reader.
If you look at that link above, all the news items run down the middle of the page. I modified the news reader so now its monitoring about 70 different news feeds combining them into 1 page of news. The simple feed reader works by updating the cache when people "hit" the page. I found this was very slow for slow news feeds, sometimes taking several minutes to get the update for slow feeds. So i modified the code to make my news reader update from a cron job every 3 hours instead of from page hits.
I also modified it so that each news item displays the website logo for the feed, regardless of weather the website has a logo or not, i make all the logo's and store them on my website. Each news item also displays a kind of small "News story image" inside each news item. These images do not come from the news item, i have them stored on my website and i wrote a script to detect each feed and add a random news story image associated with that particular news feed. I kinda add apple pictures to news feeds about apples, and pictures of oranges to news feeds with news about oranges, its an analogy if you know what i mean.
The end result is perfect but the code is now vastly different to the simple feed reader and currently it will only work inside my particular website. It took 3 and a half months to perfect the script. I considered re-releasing this as a new Joomla mod but there would be a massive amount of work involved in making the new script work outside my particular website because of all the custom code i wrote.
When you look at the link above, keep in mind that all the feeds are quite boring and none of the feeds have images or logo's in the feeds, only text. All of the images you see on the page are stored on my website and automatically added to each appropriate news item. I also added little icon's for the links to each news feed website and each news item link. I also have a fleet of other stuff that now takes this same 70 news feeds info and uses it for other stuff that is more complex.
John.
Yes, i got this to work perfectly, take a look; www.unitedboinc.com/en/project-news
The only problem is that i ended up re-writing the vast majority of the code to make the simple feed reader work the way i wanted it too. So now the code i have is vastly different to the simple feed reader.
If you look at that link above, all the news items run down the middle of the page. I modified the news reader so now its monitoring about 70 different news feeds combining them into 1 page of news. The simple feed reader works by updating the cache when people "hit" the page. I found this was very slow for slow news feeds, sometimes taking several minutes to get the update for slow feeds. So i modified the code to make my news reader update from a cron job every 3 hours instead of from page hits.
I also modified it so that each news item displays the website logo for the feed, regardless of weather the website has a logo or not, i make all the logo's and store them on my website. Each news item also displays a kind of small "News story image" inside each news item. These images do not come from the news item, i have them stored on my website and i wrote a script to detect each feed and add a random news story image associated with that particular news feed. I kinda add apple pictures to news feeds about apples, and pictures of oranges to news feeds with news about oranges, its an analogy if you know what i mean.
The end result is perfect but the code is now vastly different to the simple feed reader and currently it will only work inside my particular website. It took 3 and a half months to perfect the script. I considered re-releasing this as a new Joomla mod but there would be a massive amount of work involved in making the new script work outside my particular website because of all the custom code i wrote.
When you look at the link above, keep in mind that all the feeds are quite boring and none of the feeds have images or logo's in the feeds, only text. All of the images you see on the page are stored on my website and automatically added to each appropriate news item. I also added little icon's for the links to each news feed website and each news item link. I also have a fleet of other stuff that now takes this same 70 news feeds info and uses it for other stuff that is more complex.
John.
Please Log in or Create an account to join the conversation.
- PROMO-ONLY
- Offline
- New Member
Less
More
- Posts: 13
15 years 2 weeks ago #19242
by PROMO-ONLY
Replied by PROMO-ONLY on topic Re: Extra feature: Include image beside each feed news item
Hi there
seems like you made it indeed.
I'm trying to find a way to display a logo for each feed too, having it on the left side.
I didn't quite understand your explanations on how you did it since the first post was not working and the second you say it does but you don't explain what you changed from the first.
Would it be possible for you to explain what you did so anybody could twist the code a little bit ?
Thanks a lot.
seems like you made it indeed.
I'm trying to find a way to display a logo for each feed too, having it on the left side.
I didn't quite understand your explanations on how you did it since the first post was not working and the second you say it does but you don't explain what you changed from the first.
Would it be possible for you to explain what you did so anybody could twist the code a little bit ?
Thanks a lot.
Please Log in or Create an account to join the conversation.
- John37309
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
15 years 1 week ago - 15 years 1 week ago #19243
by John37309
Replied by John37309 on topic Re: Extra feature: Include image beside each feed news item
OK, fair enough, i never explained how i am doing it. This will be tricky because my code is no longer anything like the simple feed reader code. But i will try post roughly how i detect the feed and add the images. But to understand this, you will need a reasonable knowledge of how to alter php code.
I have 70 rss feeds i am monitoring. So first i altered the module xml to add an extra parameter to each feed called the feed name. Its added like this;
Then from the joomla admin panel, i can give each feed a word that appears in the "title" of the feed. Example might be to look for the word "BBCnews" or "CNN". I called this parameter 'srfr_url01_word'. So from the joomla admin panel, i now have the extra parameter and i am able to add the word BBCnews or CNNnews to the first feed. Remember the word must be a word that actually appears in that particular feed title, and not a word that is used in several of my feed titles.
Then in the php script, i added some code that will search for that specific word when it checks the feeds. If it finds the word "BBCnews", it will output html code to add the BBCnews image that i have stored on my website. This is the code i use to search for the word in the title of the feed;
So the code searches srfr_url01, if it finds the word BBCnews, it will echo the extra html to add the image. The location of the image for BBCnews is another parameter that i added called $srfr_url01_img, and this is also added as a programable parameter in the module xml. Then in the joomla admin module for srfr_url01_img i am giving it the end of the image url - BBCnews-logo-image.jpg
This is the image param in the xml;
So if the php code finds the word BBCnews in the title, it adds and image that might be stored somewhere like this;
MyWebsite.com/images/pro30h/ $srfr_url01_img
or this is what its getting;
MyWebsite.com/images/pro30h/BBCnews-logo-image.jpg
************
So thats effectily how i am adding the images. I only used the example with one feed for the BBCnews, but that same code is written out and copied 70 times, once for each feed. I only change the identifacion number for the feeds.
I would post the complete code here but it would be almost useless as its all hand-written and only really matches stuff that is on my website. If you really want the complete code, i could email you the whole lot, but it would be up to youself to try to make sense of how to make it work inside another website. Its full of wierd code cos i'm not very good at programming. PM me your email address if you want it, but i don't have the time to explain all the stuff in it, its complex and full of errors, but it works for me.
John.
I have 70 rss feeds i am monitoring. So first i altered the module xml to add an extra parameter to each feed called the feed name. Its added like this;
<?php
<param name="srfr_url01_word" type="text" default="" size="60" label="Feed 1 search word" description="Add the word to search for to display the image" />
?>
Then from the joomla admin panel, i can give each feed a word that appears in the "title" of the feed. Example might be to look for the word "BBCnews" or "CNN". I called this parameter 'srfr_url01_word'. So from the joomla admin panel, i now have the extra parameter and i am able to add the word BBCnews or CNNnews to the first feed. Remember the word must be a word that actually appears in that particular feed title, and not a word that is used in several of my feed titles.
Then in the php script, i added some code that will search for that specific word when it checks the feeds. If it finds the word "BBCnews", it will output html code to add the BBCnews image that i have stored on my website. This is the code i use to search for the word in the title of the feed;
<?php $match = false;
$string_to_match = $params->get('srfr_url01_word');
$word = $feed->get_title();
{if(strchr($string_to_match, rtrim($word)) !== false){$match = true;
}}
if($match == true){echo '<img src="images/pro30h/'.$srfr_url01_img.'" alt="'.$srfr_url01_word.'"
title="'.$params->get('srfr_url01_word').'">';
}?>
So the code searches srfr_url01, if it finds the word BBCnews, it will echo the extra html to add the image. The location of the image for BBCnews is another parameter that i added called $srfr_url01_img, and this is also added as a programable parameter in the module xml. Then in the joomla admin module for srfr_url01_img i am giving it the end of the image url - BBCnews-logo-image.jpg
This is the image param in the xml;
<?php
<param name="srfr_url01_img" type="filelist" directory="/images/pro30h" default="" label="Feed 1 image URL" description="Add an image to display with this news item" />
?>
So if the php code finds the word BBCnews in the title, it adds and image that might be stored somewhere like this;
MyWebsite.com/images/pro30h/ $srfr_url01_img
or this is what its getting;
MyWebsite.com/images/pro30h/BBCnews-logo-image.jpg
************
So thats effectily how i am adding the images. I only used the example with one feed for the BBCnews, but that same code is written out and copied 70 times, once for each feed. I only change the identifacion number for the feeds.
I would post the complete code here but it would be almost useless as its all hand-written and only really matches stuff that is on my website. If you really want the complete code, i could email you the whole lot, but it would be up to youself to try to make sense of how to make it work inside another website. Its full of wierd code cos i'm not very good at programming. PM me your email address if you want it, but i don't have the time to explain all the stuff in it, its complex and full of errors, but it works for me.
John.
Please Log in or Create an account to join the conversation.
- PROMO-ONLY
- Offline
- New Member
Less
More
- Posts: 13
15 years 1 week ago #19244
by PROMO-ONLY
Replied by PROMO-ONLY on topic Re: Extra feature: Include image beside each feed news item
Thanks a lot for taking the time to explain, John.
I'll take a close look to this during the w-e, I'm also trying to get the 2.0 version working correctly so that's a nice couple of days...
Too bad they didn't include this option in the new module, great to have the pictures with resizing and all but with possibility to have a defined picture for all source feed would have made it the ultimate free rss feeder.
Anyway, thanks again for your help !
I'll take a close look to this during the w-e, I'm also trying to get the 2.0 version working correctly so that's a nice couple of days...
Too bad they didn't include this option in the new module, great to have the pictures with resizing and all but with possibility to have a defined picture for all source feed would have made it the ultimate free rss feeder.
Anyway, thanks again for your help !
Please Log in or Create an account to join the conversation.
- John37309
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
15 years 1 week ago - 15 years 1 week ago #19245
by John37309
Replied by John37309 on topic Re: Extra feature: Include image beside each feed news item
mcflies,
I will take a look. I just downloaded the 2.0 version from the site, i have not looked at this in several months.
I have some spare time today, if in the space of a few hours, i can adapt the 2.0 version of the simple reader to add the images like on my website, i will post a link to download the alternative new code. You could call it;
"Simple feed reader - add your own images to feed news"
If i don't post back to this message in the next two or three days, then i got called out to another job. This extra will again be put on the back burner because of time constraints. I will try my best if time allows.
John.
I will take a look. I just downloaded the 2.0 version from the site, i have not looked at this in several months.
I have some spare time today, if in the space of a few hours, i can adapt the 2.0 version of the simple reader to add the images like on my website, i will post a link to download the alternative new code. You could call it;
"Simple feed reader - add your own images to feed news"
If i don't post back to this message in the next two or three days, then i got called out to another job. This extra will again be put on the back burner because of time constraints. I will try my best if time allows.
John.
Please Log in or Create an account to join the conversation.
- John37309
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
15 years 1 week ago - 15 years 1 week ago #19246
by John37309
Replied by John37309 on topic Re: Extra feature: Include image beside each feed news item
OK, its done it you want to try this new version. Its a modified version of the brand new code from joomlaworks on the 12th Nov 2009. But i have added lots of extra code and images and stuff.
****************************
Installation procedure for Simple feed reader with news feed logos
Download the new modified simple feed reader logo version here;
www.boincteams.com/testpages/mod_jw_srfr-v2.0_j15-v-logos.zip
**********
Currently this mod only works properly using the JA_Purity template because its the only one that has the module position "banner"!
1. Enable JA_Purity template
2. I'm not really sure, but its probally best to uninstall the other version of the simple feed reader. Maybe you can get away with just installing on top of the other version, i'm just not sure.
3. Create an article that will be the title and explaination of the type of combined news you are displaying on the page. Then hide the author name, article publishing date, PDF Icon, Print Icon and E-mail Icon. This will just leave you with what looks like a general page title.
4. Create a new menu item as an "article layout", thats just a single article, that article being the short feed reader explaination article you just wrote. So when you click that menu item, it only displays that one short single article at the top of the page.
5. Download and install the feed logo version of the simple feed reader.
6. Create a new simple feed reader module and give it a Menu Assignment so that the module is only displayed on the menu item page for your new article. The module position should be in the "banner" position!. And "Choose layout template", select the option called "wide".
Finished! , this should display 3 news feeds with the approperate feed logo beside each feed. There are 3 example feeds, ABC news, BBC news and CNN news as the default install. There are 3 example images for each news feed that come with the logo version of the mod. There is also a blank glass PNG image and an example 84 pixel by 22 pixel image that you can use as templates to make your own feed logos if you like the glass button design i made.
Example of the finsihed logo version of the feed reader is here;
www.boincteams.com/testpages/Joomla1-5-15b/index.php?option=com_content&view=article&id=46&Itemid=53
Notes;
With this logo version of the simple feed reader, you have to make your own feed logos and put them in the "feedlogos" folder!
Its important to remember that this logo version only has enough code to add logos to the first 5 feeds. If you are monitoring more than 5 feeds, you need to edit mod_jw_srfr.xml and copy the code on line 68 and 69 to match the number of feeds you have. You must also do this in mod_jw_srfr.php copying lines 59 and 65. You must also do it in the file tmpl/wide/default.php copying lines 49, 50, 51 and 52. In each of the cases mentioned, you copy the code and just change the numbers marking each peice of code. You will just have to try understand the sequence you see and copy the code format just changing the didgits from 01 to whatever.
Also, when you add a new feed, the word associated with that feed, programmed from the admin module, needs to be exactly the same as the title of the feed you are monitoring, the spelling must be exactly the same and it should be the full name of the feed. You cannot invent the name that you perfer yourself. If the feed title is "BBC News | News Front Page | World Edition", thats what you must use as the search word. You can't call it just "BBC news" or my code won't find a match and add the image.
If you try it, please do post back here and let me know how it goes. Please do forgive my poor coding, i'm not very good at this, i'm just learning this stuff as i go along.
Also, if the forum admin here at JoomlaWorks.net wants to use this code, your more than welcome. Thanks for creating a really great module in the first place.
John.
****************************
Installation procedure for Simple feed reader with news feed logos
Download the new modified simple feed reader logo version here;
www.boincteams.com/testpages/mod_jw_srfr-v2.0_j15-v-logos.zip
**********
Currently this mod only works properly using the JA_Purity template because its the only one that has the module position "banner"!
1. Enable JA_Purity template
2. I'm not really sure, but its probally best to uninstall the other version of the simple feed reader. Maybe you can get away with just installing on top of the other version, i'm just not sure.
3. Create an article that will be the title and explaination of the type of combined news you are displaying on the page. Then hide the author name, article publishing date, PDF Icon, Print Icon and E-mail Icon. This will just leave you with what looks like a general page title.
4. Create a new menu item as an "article layout", thats just a single article, that article being the short feed reader explaination article you just wrote. So when you click that menu item, it only displays that one short single article at the top of the page.
5. Download and install the feed logo version of the simple feed reader.
6. Create a new simple feed reader module and give it a Menu Assignment so that the module is only displayed on the menu item page for your new article. The module position should be in the "banner" position!. And "Choose layout template", select the option called "wide".
Finished! , this should display 3 news feeds with the approperate feed logo beside each feed. There are 3 example feeds, ABC news, BBC news and CNN news as the default install. There are 3 example images for each news feed that come with the logo version of the mod. There is also a blank glass PNG image and an example 84 pixel by 22 pixel image that you can use as templates to make your own feed logos if you like the glass button design i made.
Example of the finsihed logo version of the feed reader is here;
www.boincteams.com/testpages/Joomla1-5-15b/index.php?option=com_content&view=article&id=46&Itemid=53
Notes;
With this logo version of the simple feed reader, you have to make your own feed logos and put them in the "feedlogos" folder!
Its important to remember that this logo version only has enough code to add logos to the first 5 feeds. If you are monitoring more than 5 feeds, you need to edit mod_jw_srfr.xml and copy the code on line 68 and 69 to match the number of feeds you have. You must also do this in mod_jw_srfr.php copying lines 59 and 65. You must also do it in the file tmpl/wide/default.php copying lines 49, 50, 51 and 52. In each of the cases mentioned, you copy the code and just change the numbers marking each peice of code. You will just have to try understand the sequence you see and copy the code format just changing the didgits from 01 to whatever.
Also, when you add a new feed, the word associated with that feed, programmed from the admin module, needs to be exactly the same as the title of the feed you are monitoring, the spelling must be exactly the same and it should be the full name of the feed. You cannot invent the name that you perfer yourself. If the feed title is "BBC News | News Front Page | World Edition", thats what you must use as the search word. You can't call it just "BBC news" or my code won't find a match and add the image.
If you try it, please do post back here and let me know how it goes. Please do forgive my poor coding, i'm not very good at this, i'm just learning this stuff as i go along.
Also, if the forum admin here at JoomlaWorks.net wants to use this code, your more than welcome. Thanks for creating a really great module in the first place.
John.
Please Log in or Create an account to join the conversation.
- PROMO-ONLY
- Offline
- New Member
Less
More
- Posts: 13
15 years 1 week ago #19247
by PROMO-ONLY
Replied by PROMO-ONLY on topic Re: Extra feature: Include image beside each feed news item
whoa great, thanks for your time making this.
I will try this and let you know how it goes even though I'm not using the ja purity template at all and publishing the feeds in modules position, not as article.
have a great w-e.
I will try this and let you know how it goes even though I'm not using the ja purity template at all and publishing the feeds in modules position, not as article.
have a great w-e.
Please Log in or Create an account to join the conversation.
- Forum
- Free Joomla Extensions & Templates
- Simple RSS Feed Reader
- Extra feature: Include image beside each feed news item