Loading...
 
Features / Usability

Features / Usability


Filter external feed?

posts: 28
Is there any way to Filter the external feeds? Election year is rather annoying and My viewers would prefer to not see that kind of stuff.
posts: 214

Warning, the following suggests making changes to Tiki code, use at your own risk.

There isn't currently an external feed filter option. You could make the code change below to add one.

Create a tracker, name does not matter, keep the tracker ID number.
Add a field to the tracker, Type: Text field, name does not matter, keep the field ID number.
Use this tracker to hold the filter strings.

At the top of lib/rss/rsslib.php, before the lines:

Copy to clipboard
class RSSLib extends TikiDb_Bridge {


Add these lines so it looks like:

Copy to clipboard
global $rssfilterwordlist; $rssfilterwordlist = TikiLib::lib('trk')->get_all_items("tracker id number","field id number",'opc'); class RSSLib extends TikiDb_Bridge {

Put your Tracker id number where it has "tracker id number" and field id number where it has "field id number".

Then in the function, insert_item, change these lines:

Copy to clipboard
private function insert_item( $rssId, $data, $actions ) { $this->items->insert(

to

Copy to clipboard
private function insert_item( $rssId, $data, $actions ) { global $rssfilterwordlist; foreach ($rssfilterwordlist as $filterword) { if (strpos($data['description']." ".$data['title'], $filterword) !== FALSE) { return; }} $this->items->insert(


Insert the word(s) you want to filter in the tracker.

Filter is case sensitive. Be careful, the filter word will be matched even if it is part on another word, "election" will reject "selection".
Padding filter words with space does not work, but you can have multiple words with spaces in between them as a filter word.

The code above applies the filter to both the "title" and "description". You could change it to "strpos($data['title'], $filterword)", if you only want the filter words applied to the "title", or "strpos($data['description'], $filterword)" , if you only want the filter words applied to the description.

I think this will work in Tiki 9 through Tiki 15, but I only tested it on Tiki 14.

Tom


posts: 1817 Catalan Countries

Hi Tom and dracozny

Feel free to commit a general solution for Tiki (maybe add a text area in the corresponding "Control panel" so that the word list can be set as a preference (without the need to set up trackers for that), and then get the RSS feeds filtered as you say?

See how to get commit access:

https://dev.tiki.org/Commit

and what's the development model of Tiki:
https://tiki.org/Model

Welcome to the Tiki Community! :-)


Upcoming Events

1)  18 Apr 2024 14:00 GMT-0000
Tiki Roundtable Meeting
2)  16 May 2024 14:00 GMT-0000
Tiki Roundtable Meeting
3)  20 Jun 2024 14:00 GMT-0000
Tiki Roundtable Meeting
4)  18 Jul 2024 14:00 GMT-0000
Tiki Roundtable Meeting
5)  15 Aug 2024 14:00 GMT-0000
Tiki Roundtable Meeting
6)  19 Sep 2024 14:00 GMT-0000
Tiki Roundtable Meeting
7) 
Tiki birthday
8)  17 Oct 2024 14:00 GMT-0000
Tiki Roundtable Meeting
9)  21 Nov 2024 14:00 GMT-0000
Tiki Roundtable Meeting
10)  19 Dec 2024 14:00 GMT-0000
Tiki Roundtable Meeting