Hello everyone. I was wondering if it would be possible to create a RSS Feed for a collection of images? I’ve tried to edit the feed.php with the same method I’m using in my template, but that seems to break the whole feed, resulting in an empty <body>. Not shure what I’m doing wrong, or if this is even the right approach, so any help would be greatly appreciated. Here’s how it currently looks:
Now that you have your pages listed, let’s talk about adding images. The feed plugin doesn’t have this built-in. Let’s add it! Edit template.php in site/plugins/feed
Add `the following on line 22 (just below the description)
This may not cover your needs if you have several images per child page of screenshots. Not knowing your content structure, I can only hope this works
You could also modifiy the code I gave you to fetch the last modified image from each page:
Change $item->image() to $item->images()->sortBy('modified', 'desc')->first();
You may also want to modify where the title and description in the template.php file are taken from. Right now, it will be from the page containing the image and not from the image itself.
NB: I have no way of testing any of the code I’m giving you right now. Please double-check everything works right for you!
Wow, what a detailed answer, thank you! Sadly (as you have already guessed), there are several images in the child pages and I would like to have an entry for each of them, so looping through the pages alone isn’t going to work. My content structure looks somewhat like this:
- Screenshots
- Project a
- image1.jpg
- image2.jpg
- Project B
- image3.jpg
- image4.jpg
- Project C
- image5.jpg
- image6.jpg
- image7.jpg
Your code is perfect for a Blogfeed though, and I’ll probably use it for that, since it works fine. It’s just not working for my initial idea. And I’m aware that my structure may be pushing the plugin a bit, so if it really isn’t meant for looping through images, I guess there isn’t much I can do to achieve this?
There’s always something you can do and the flexibility of Kirby is amazing
What would your XML entry look like? Can you look at the template.php and list the fields you’d need? You mentioned wanting to get the title and caption from the image. Are those custom file fields?
I’m sure we’ll find a solution for you! If it leaves the reach of my skillset, there are many way more talented devs here that’ll know just the perfect way to do this!
That’s one way of doing it but it would result in all the images of a page being listed for the 10 most recent pages.
If I understand what @Swissendo wants, it’s the 10 most recent images, regardless of the page it’s from.
Is that a correct assumption?
Yes, that is a correct assumption. As far as I can understand, the solution from @texnixe would list the ten most recent pages, each containing all images of them, just like you’ve said. What I want is to bundle all images together, sort them by the modified date and output the 10 most recent images. I want something similar to a Flickr RSS Feed, to give an example.
As for the XML: The caption and title are custom file fields, yes. At first I thought I could just use $item->caption() and $item->title() inside the <description>, if the plugin recognizes the images as an $item, but it seems that’s exactly where the main problem is. Either way, thank you both for your answers and support so far!
It should not be too difficult to rewrite the plugin so that it supports images instead of pages. Currently, it creates a new pages method, so you would have to create a new files method “feed”.
@Thiousi: As I said above, with the current way the plugin works, it is page based, so there is no feed method on images. It simply won’t work. So this code:
@Thiousi. Well, sorry, I was set on the wrong track by your last post, because the problem is not related to the blueprint with the titles and captions.
Anyway, @swissendo, I think it is worth a try to adapt the feed plugin by using a files method instead:
@texnixe: I’ve tried to adapt the files to the best to my knowledge (which probably means I’ve made a ton of mistakes), yet nothing changed. Here’s how my files look so far:
Yes, I have. I’ll probably need to change something in my xampp first though, because php_error_log doesn’t seem to exist.
Do you mean the blueprint for the panel? There isn’t much to it, the only fields of interest are title and caption, plus some other stuff that isn’t relevant to this question.
No, I haven’t. But some of them have both, so at least these should show up, I think?
Pls. try to enable debugging or check where your php_error_log is located, there should be a folder called logs somewhere. What version of XAMPP is that? Are you on Windows?
Debugging is enabled, it just doesn’t seem to output anything regarding the RSS Feed. If I purposely create an error by changing $page to $pagee or something similar, it shows up in my php_error_log.txt. Visiting the Feed URL doesn’t ouput anything.