I am writing a plugin, but I dont know which event to use.

Development-related discussion, including bundled plugins
laapsaap
Bear Rating Trainee
Bear Rating Trainee
Posts: 3
Joined: 14 Oct 2013, 17:20

I am writing a plugin, but I dont know which event to use.

Postby laapsaap » 14 Oct 2013, 17:24

Hi,

I am trying to write a plugin for tt-rss and I have looked at classes / pluginhost.php.

What I want to do is, is to fire a function for each new article from all the feeds. Which hook is the right one for this job? Some pointers would be appreciated! Thank you.

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: I am writing a plugin, but I dont know which event to us

Postby fox » 14 Oct 2013, 17:55

"For each new article" - that depends, when they are displayed or imported by the backend?

laapsaap
Bear Rating Trainee
Bear Rating Trainee
Posts: 3
Joined: 14 Oct 2013, 17:20

Re: I am writing a plugin, but I dont know which event to us

Postby laapsaap » 14 Oct 2013, 19:01

When its imported by the backend

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: I am writing a plugin, but I dont know which event to us

Postby fox » 14 Oct 2013, 20:21

HOOK_ARTICLE_FILTER

laapsaap
Bear Rating Trainee
Bear Rating Trainee
Posts: 3
Joined: 14 Oct 2013, 17:20

Re: I am writing a plugin, but I dont know which event to us

Postby laapsaap » 15 Oct 2013, 00:23

Thanks, its working. Really like the plugin system, so easy to use.

I was just wondering now I use HOOK_ARTICLE_FILTER and use $article["link"]. What is the best way to only process the new updated articles? Because now it returns all the links in the feeds. Thanks

feader
Bear Rating Master
Bear Rating Master
Posts: 160
Joined: 26 Dec 2012, 20:03

Re: I am writing a plugin, but I dont know which event to us

Postby feader » 15 Oct 2013, 00:48

laapsaap wrote:I was just wondering now I use HOOK_ARTICLE_FILTER and use $article["link"]. What is the best way to only process the new updated articles? Because now it returns all the links in the feeds.

You can use the $article['plugin_data'] entry for such stuff. Be careful not to override it, append your stuff to it. See here and here how this can be done.

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: I am writing a plugin, but I dont know which event to us

Postby fox » 15 Oct 2013, 09:19

Yeah, above is correct, I don't think you can explicitly hook only for *new* articles, you have to check with plugin_data if you have processed this one before or not. See af_* plugins for an example.

carlos-
Bear Rating Trainee
Bear Rating Trainee
Posts: 4
Joined: 23 May 2013, 16:10

Re: I am writing a plugin, but I dont know which event to us

Postby carlos- » 31 Oct 2013, 00:30

can you guys give some tips on how to handle unicode in plugins? I know php doesn't natively support utf8, and I am not that experienced in php programming.

I created a plugin which does some reformatting similar to the slashdot iframe width handler and removing some elements. It gives a different output depending on the hook I use.

HOOK_ARTICLE_FILTER -> unicode characters garbled, e.g. Brazil’s instead of Brazil's
HOOK_RENDER_ARTICLE_CDM -> unicode characters seem to show correctly

I think that the HOOK_RENDER_ARTICLE_CDM isn't invoked when accessing the feeds via the mobile app. At least that is what I noticed because I prefix the article of an entry that has been processed and the app doesn't show the title just like it would in the web application.

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: I am writing a plugin, but I dont know which event to us

Postby fox » 31 Oct 2013, 13:13

google -> mbstring

e: Your "please teach me unicode in php kthxbye" question has nothing to do with tt-rss. This is not a PHP learning forum.

carlos-
Bear Rating Trainee
Bear Rating Trainee
Posts: 4
Joined: 23 May 2013, 16:10

Re: I am writing a plugin, but I dont know which event to us

Postby carlos- » 01 Nov 2013, 01:56

I never asked for a tutorial, just a fucking simple question with some side info on my behalf.

why don't you explain the difference in behavior between the two hooks instead of acting like a dick?

User avatar
sleeper_service
Bear Rating Overlord
Bear Rating Overlord
Posts: 884
Joined: 30 Mar 2013, 23:50
Location: Dallas, Texas

Re: I am writing a plugin, but I dont know which event to us

Postby sleeper_service » 01 Nov 2013, 02:51

ever hear the old one about catching more flies with honey?

vitriol doesn't really attract them... good luck with your new method of extracting information.

ps, read the faq.

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: I am writing a plugin, but I dont know which event to us

Postby fox » 01 Nov 2013, 08:55

carlos- wrote:why don't you explain the difference in behavior between the two hooks instead of acting like a dick?


Unicode-wise there's no difference. HTH. :D

shabble
Bear Rating Trainee
Bear Rating Trainee
Posts: 33
Joined: 18 Mar 2013, 23:40

Re: I am writing a plugin, but I dont know which event to us

Postby shabble » 01 Nov 2013, 13:38

carlos- wrote:can you guys give some tips on how to handle unicode in plugins? I know php doesn't natively support utf8, and I am not that experienced in php programming


carlos- wrote:I never asked for a tutorial, just a fucking simple question with some side info on my behalf.



You explicitly asked for a tutorial. Along with your other question(s).


Return to “Development”

Who is online

Users browsing this forum: No registered users and 1 guest