Author Topic: multi-category rss feed  (Read 10460 times)

0 Members and 1 Guest are viewing this topic.

Offline surferboy

  • Full Member
  • ***
  • Posts: 142
    • View Profile
multi-category rss feed
« on: September 15, 2010, 06:57:50 AM »
In my search of the forums, it would not appear that anyone has asked the question of how to create an RSS feed that pulls images from the one of the top categories and all sub-categories below.

Is that possible?

I know that an external news aggregator could do that but it would require constant updating as new sub-categories were added, and the chances of displaying the the thumbnails from all the sub-categories is not likely in a aggregator widget.

Thanks,

Brian

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: multi-category rss feed
« Reply #1 on: September 15, 2010, 03:23:15 PM »
Not tested, in rss.php find:
      $cat_sql "AND i.cat_id = $cat_id";

Replace with:
      $subcat_ids = array();
      
get_subcat_ids($cat_id$cat_id$cat_parent_cache);

      
$cat_sql "AND i.cat_id IN($cat_id".(isset($subcat_ids[$cat_id]) ? ",".implode(","$subcat_ids[$cat_id]) : "").")";
« Last Edit: September 16, 2010, 03:29:37 AM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline surferboy

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: multi-category rss feed
« Reply #2 on: September 15, 2010, 06:39:46 PM »
Hi -

using v1.7.7
mysql 5.1.47
php 5.2.13

WOW! Bit of some Chinese food I'm afraid - sweet and sour ...

For our super categories, in the words of entire British Empire: brilliant. Yes it works exactly as I had hoped.  What I mean by super categories are those top level categories where we have disabled members from uploading images directly into that first level category. Instead, the images are uploaded in the sub-categories. All images appear as per the specification of the number of images and date of upload.

But what doesn't work and causes a mysql parsing error, is to click the rss button on any category that only has images directly in that category.  The mysql parsing error does not appear for a category that does have images directly in the category if there are images in one or more subcategories.  In that scenario, the images at the current category level are simply ignored.

Here is the parsing error, edited to remove our domain information:

XML Parsing Error: junk after document element
Location: http://www.xxxx.com/ourgallery/rss.php?action=images&cat_id=178
Line Number 2, Column 1:<b>Warning</b>:  implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed in <b>/home1/xxxxx/public_html/ourgallery/rss.php</b> on line <b>238</b><br />
^

Thanks so much for your help in trying to make this work.

Brian

Offline V@nо

  • Addicted member
  • ******
  • Posts: 1.223
    • View Profile
Re: multi-category rss feed
« Reply #3 on: September 16, 2010, 01:48:22 AM »
Oh, I knew I forgot something...
I'll update my code later, but for now replace
      $cat_sql "AND i.cat_id IN(".implode(","$subcat_ids[$cat_id]).")";

with:
      $cat_sql "AND i.cat_id IN(".(isset($subcat_ids[$cat_id]) ? implode(","$subcat_ids[$cat_id]) : $cat_id).")";
Your first three "must do" before you ask a question:
If I asked you to PM me, I meant PM to my primary account, this account doesn't accept PMs.

Offline surferboy

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: multi-category rss feed
« Reply #4 on: September 16, 2010, 02:25:38 AM »
Hi -

Thank you so much, once again. We're almost there!  The parse error is gone and in my initial testing, everything seemed to be working perfectly.  I checked the current categories that had images and also had subcategories images and clicked the RSS button. The RSS feed came back fully populated, and I presumed the images in the current level category had just been uploaded earlier than the ones in the sub category.

However, I checked one category that had two images in the current level and 5 images in the subcategory. Clicking the RSS feed button returned all 5 of the subcategory images but not the 2 current level images.  I checked my RSS.php file and double checked the image default: @define('RSS_DEFAULT_ITEMS', 10);

Unless there is a code setting for # days since upload, which there certainly could be ..., that means the current level images are still being ignored.

[edit] forgot to mention: if all the images are in the current level and there is no subcategory [edit3], and I click on the RSS feed button, it works just fine.  I'll test a new scenario by adding a subcategory to this current level category, but without any pics, and see what happens ..

[edit2] aha! as soon as I did add an empty subcategory under the current level and clicked on the RSS feed button, the RSS feed returned completely blank ...

since I know some of the images in the current level were just uploaded today, I know it isn't a # days since upload issue.

What do you think?

Thanks again for your time on this.

Brian

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: multi-category rss feed
« Reply #5 on: September 16, 2010, 03:30:39 AM »
I've updated my original code, it should work now.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline surferboy

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: multi-category rss feed
« Reply #6 on: September 16, 2010, 04:06:44 AM »
Yep, totally works like a charm.  THANK YOU SO MUCH!   :D

For our website, where the 4images gallery is just one component, this MOD or tweak allows us to create RSS widgets for every one of our 33 country pages. When a community member goes to that page, they will be able to see all the images recently uploaded for that country category and any subcategories under that.  This finesse of the code makes the integration of 4images so incredibly valuable. 

Similarly, we have 6 athlete pages for focused athlete interest, and we have a matching 6 athlete categories on our 4images gallery. This is pure gold.

Again, thanks so much. If you would like me to take the time to turn this into a micro MOD instead of your having to do the work, just let me know. It's the least I can do.

- Brian

Offline surferboy

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: multi-category rss feed
« Reply #7 on: October 29, 2010, 05:31:21 AM »
Strange issues with multiupload on RSS display.

Using v1.7.7
php version 5.2.14
mysql version 5.1.47

After lots of success on getting the RSS to display for a given category and all categories below, we seem to have a hiccup that I thought only  happened with multiupload.  Now it seems that any upload by ftp, or multiupload does not create an upated RSS display.  Only the individual uploaded images are allowing the RSS feed to update.

[edit] issue solved - in edit categories in the 4images admin control panel, you need to have selected "all' for view category and view image

 :oops:

Thanks,

Brian
« Last Edit: October 31, 2010, 04:17:37 PM by surferboy »

Offline surferboy

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: multi-category rss feed
« Reply #8 on: June 30, 2012, 06:45:02 AM »
Arrrggghhh!  Vano... you had totally done it. For over 2 years, this rss tweak you created worked perfectly.

But now that I have changed servers, the rss feeds don't work anymore!!!

Do I need to change something in the rss.php file?

Thanks for any ideas.

Brian

Offline Jan-Lukas

  • Addicted member
  • ******
  • Posts: 1.289
    • View Profile
    • Discover the New World of Kindersurprise
Re: multi-category rss feed
« Reply #9 on: June 30, 2012, 06:19:15 PM »
Wenn ich das richtig sehe, müsste das in Version 1.7.10 schon so drin sein
Danke Harald




Offline surferboy

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: multi-category rss feed
« Reply #10 on: June 30, 2012, 06:36:19 PM »
Hi -

I apologize for not indicating what version I am using.  It is v1.7.7

In this topic, Vano helped me tweak the rss.php file so that I could display separate rss feeds for each category and all subcategories underneath.

However, after I moved all of our files to the new vps server, now the rss feeds do not work.  It is strange, if you click on the rss button, it does take you to what we all think is a usual rss feed page, with the images displayed and the descriptions ... so at first glance it works but if you use the feed in a widget, the feed is determined to be a web page and not a real rss feed.

Happy to PM you examples or let you see on our site if you like. I just can't post our site's link here on the forum.

Thanks,

Brian

Issue resolved

Turns out it was an .htaccess rule that did not carry over from the old server. Thanks to any and all who tried to assist.

« Last Edit: July 06, 2012, 09:30:29 AM by surferboy »