I’m working with the very nice Twigfeeds plugin and wondered if anyone else had ever done any work to group feeds by some kind of label, using this plugin. I’d like to be able to group feeds into ‘News’, ‘Blogs’, ‘People’ or ‘Organisations’ or other categorisation, and then sort them into being displayed in a template according to their label/category. Maybe this could be done either by adding another field to the form in the plugin for a label or category, or maybe having some method of doing this in a template by assigning a category there. (NB Im not looking to store any of the feed results.)
I’m already using a simple if/else to display Bluesky and Mastodon feeds with a slightly different template to ‘normal’ blog feeds, due to them not having an item title, so maybe this method of sorting could be extended further for categorisation.
Ive made some progress on this, but am stuck at the point where I think I need to add ‘category’ to a php array in some way. Possibly either to twigfeeds.php or to Manifest.php.
Ive added ‘category’ to the plugin blueprints and languages yaml files, with relevant info:
user/plugins/twigfeeds/blueprints.yaml
.category:
type: text
label: PLUGIN_TWIGFEEDS.ADMIN.OPTIONS.TWIG_FEEDS.CATEGORY.LABEL
description: PLUGIN_TWIGFEEDS.ADMIN.OPTIONS.TWIG_FEEDS.CATEGORY.DESCRIPTION
user/plugins/twigfeeds/languages.yaml
CATEGORY:
LABEL: Category
DESCRIPTION: A name for the category, eg people or news
Ive also added category info to a few feed sources in user/config/plugins/twigfeeds.yaml. Eg:
This all shows up in the Twigfeeds plugin admin panel.
Adding {{ category }} to the twig template would make the category info show up (if it’s defined!) so I need to add something to the php somewhere. I get an error at the moment of "Undefined array key "config_file"", referring to line 117 in Manifest.php - $this->configFile = $config['config_file'];. Im thinking tis may well refer to something defined somewhere else, eg twigfeeds.php. Maybe not. I dont know.
So Im stuck. Ive looked a lot at where might be how to do this but at the moment I cannot figure it out.
Update.
I think I solved it. I was wrong about having to add anything to any php file. The solution was very simple. If everything is in place as shown in the previous post, just use {{ feed.category }} to call each group in twig templates and it works. This means that it is now possible to groups feeds into various categories that can be collected together or shared into other areas as a single group of feeds.
That is a rather elegant solution, adding metadata where it was not originally expected and utilizing it to organize the data. I added it to the README for future reference.
Thanks, I really appreciate that. It’s a very good plugin, but I think with categorisation it provides a lot more power, as we can now manage a greater number of feeds in very specific ways. RSS is enjoying a bit of a renaissance due to bigtech negativity so maybe this contributes positively to that.
I was wondering, should I move the customised blueprints and languages yaml files to the user/config area to avoid being overwritten in an update process?
Unfortunately it breaks the plugin if you move blueprints and languages yaml files to user/config/plugins, even if they’re loose in that folder. So best to just keep a record of changes/additions to those files and then replace after any plugin upgrade.
(For the benefit of new users, twigfeeds.yaml in user/config/plugins would be unaffected by updating the plugin.)
Edit
I noticed that in the github readme the urls for the blueprints and languages files are incorrect. They should be user/plugins/twigfeeds/blueprints.yaml and user/plugins/twigfeeds/languages.yaml. So, not in the user/config.
I’ll change it to that. My memory on this is a bit sketchy, as it’s been a few years since I worked with advanced and programmatic manipulation of blueprints. The files likely have to co-exist as the original source within user/plugins/twigfeeds/*, and be overridden by user/config/plugins/twigfeeds/*. This should be handled without extra effort by Grav and Admin’s internals, but could possibly need extending.
In any case, it’s a worthwhile use-case to add the user-defined or default taxonomy to the plugin’s blueprint from site.yaml. If someone wants to wrestle a bit with it, it would be a good pull request to merge, and a good addition to the Cookbook-section of the docs.
Yes you are right re placing duplicate files in the user/config/plugin - I forgot that you don’t move them, you duplicate and edit, to override in a hierarchy of processing. That seems to work fine.
Update - unfortunately, placing languages and blueprint yaml files (duplicates, edited) in user/config/plugins does not override the standard plugin form, which loses the ‘category’ field. The front end is intact which was why I initially thought it worked (duh) but blueprints and languages are backend only and dont seem to override.
Ive already thought about how default taxonomies might work with this - I’ll look into it a bit (as I run various taxonomy stuff in my other Grav site) and test with template calls. Its probably beyond my skillset to go into it deeply in terms of your repo or the official docs etc but Im happy to help if I can.
As it turns out, there’s quite a lot about how blueprints are handled that cause issues. I’ve revised the README and published a pre-release in v5.1.0-beta.1, which solves this minimally by destructuring blueprints.yaml into blueprints/plugins/twigfeeds/*.yaml. The superfluous path is necessary for user/blueprints/plugins/twigfeeds/*.yaml to work without programmatic interference.
The natural solution to allow for default taxonomies would be:
But in testing that almost without fail caused some cyclical regression that exhausted memory and crashed the site. Regardless, the new structure allows for any form-fields to be utilized.
If you have opportunity to test the beta, that would be appreciated.
@OleVik Sorry Ive been so slow to do this testing. I REALLY want to get to it, but am overran with other work I must do at the moment.
I intend to test with templates for usual taxonomy behaviour eg tag cloud, category or tag collection pages. I have these running on my personal site (penworks.net) so this is where Id start. To see if its workable like this. I’ll be in touch asap.
hahaha! Well I hope to get to it quicker than that!!
Im very interested in independent ways of managing RSS. Im also aware that Hibbitts Design Grav learning course templates include Twigfeeds and if Twigfeeds could manage the feeds more effectively I would think it might be very useful in those or similar contexts. Perhaps Paul already does something like this with Twigfeeds in his templates, I dont know.
My work with Ole’s Twigfeeds plugin was more about creating a specific page type to support the basic selection and display of RSS feeds. I am not a dev so I am sure my scripting could be greatly improved You can find this work in my bootstrap4-open-matter theme, which is used my open course hub skeletons. Hope something there might be of help! Ole’s awesome plugin enabled me to create course-specific RSS feeds and manage them pretty easily.
@paulhibbitts thanks for your valuable input. I wonder what you think of this: Whenever Ive developed course learning areas (in whatever platform) I would use different feeds for different weeks or topics. In this case, if Twigfeeds can categorise and tag, it would make that use of the plugin very versatile in this context. Do you think if you could do this with the plugin that your learning course templates would benefit your users?
I really couldn’t say, for the most part the courses I’ve seen built with my Course Hub skeletons don’t use RSS in any way. I myself am a big fan of RSS though, and used a single feed for my own CMPT-363 course on user interface design, for example UX News | CMPT 363-211
@OleVik Hi. Im just about to get back into Twigfeeds but havent yet updated, to make sure I back up the working version as it was before I change everything!
Something Im noticing is that the Blusesky RSS feed format does not work in Twigfeeds, eg: https://bsky.app/profile/did:plc:yvcc4fhujw7wjjnmjvl42iur/rss
If I use something to convert it, it immediately works. Eg https://fetchrss.com/feed/aH95VX0A0AEDaH95KRRM5ulT.rss (this is the same feed, running through Fetch RSS), Update - it sort of works, sentence titles dont link to posts, only to acct. RSS app works but is a premium service.) btw all Mastodon feeds work.
The Bluseky Rss format works if you just use plain php to call it, so not sure if I can tweak something in the plugin. Could you test, in case you get a different result? Ideally Id like to follow at least 5 Bluesky feeds in my app area.
@OleVik - Hi. Hope all good with you. So Ive been attempting to test v5.1.0. I followed the guide in the new readme but unfortunately I cant get it working. This is both in localhost (Laragon php8.1/Win) and Ionos shared LAMP hosting (php8.1). Worth saying v4 and v5 install no problem.
I run into problems as soon as I have the blueprints and language folders active. I get white (blank) pages, errors relating to undefined arrays for name or date, or errors for lines in rockettheme in the vendor folder. This affects front and back end.
No Idea if Im making a mistake somewhere, but this is prior to doing any other kind of input of tags etc.
BlueSky’s own RSS-feeds are missing some metadata, as well as data, most notably <title> from <channel> and <item>s. The parser then appears to fail to recognize the feed as valid, even though it strictly speaking is. For reference, I compared The New York Times from Bsky.app with the same via FreshRSS.com. To avoid erroring-out from a lack of explicit or implicit title or name, I added some fallbacks in v5.1.0-beta.2. But because of the format BlueSky uses, I’m afraid the parser fails to understand it.
With a clean, uncached install of Grav v1.7.48, Admin v1.10.48, TwigFeeds v5.1.0-beta.2, running PHP 8.1.13 with the built-in server on Windows 10, the recipe as presently written works for me in testing. Could you try with beta.2, and share any errors that arise in an issue on the repo?