Tweetback-Plugin for s9y?

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
oliverg
Regular
Posts: 43
Joined: Sat Feb 24, 2007 12:34 pm
Contact:

Tweetback-Plugin for s9y?

Post by oliverg »

Well,

the subject says it, is there any possibility to show Tweetbacks in S9Y? Could not find anything...

This would show if there are any referrers from twitter to a Blogpost.

Oliver
mattsches
Regular
Posts: 440
Joined: Sat Nov 05, 2005 9:35 pm
Location: Wiesbaden, Germany
Contact:

Re: Tweetback-Plugin for s9y?

Post by mattsches »

Hi Oliver,

I might take a look at this because I would like a feature like this as well, but I cannot promise anything :wink:

Regards,
- Mattsches
mattsches
Regular
Posts: 440
Joined: Sat Nov 05, 2005 9:35 pm
Location: Wiesbaden, Germany
Contact:

Re: Tweetback-Plugin for s9y?

Post by mattsches »

Ok, I started to think about it more seriously. I managed to fetch tweets from the public timeline and stuff, but now I wonder how to store them.

Looks like my plugin could define a new comment type - e.g. "TWITTER" - and insert the respective tweets into the comments table. Those can be selected with serendipity_fetchComments(), but which would be the right event hook to fetch them?

Obviously it isn't "fetchcomments" because that throws an error. "frontend_display"? But what if I want to merge the twitter comments with regular comments (ordered by timestamp)? Is this possible?

Any ideas appreciated!

- Mattsches
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Tweetback-Plugin for s9y?

Post by garvinhicking »

Hi!

This is currently not really doable without a core or template patch.

Since templates only have room for comments and trackbacks, you need to insert your pingbacks at one of these locations. I'd probably suggest to output tweetbacks in the trackbacks section.

For that, the smarty function {serendipity_printTrackbacks entry=$entry.id} is called in all entries.tpl templates. This relates to include/functions_smarty.inc.php, the serendipity_smarty_printTrackbacks() function. That one calls the serendipity_fetchTrackbacks(), and there no plugin API hooks are called. PINGBACK and TRACKBACK are hardcoded there.

So a plugin api hook would needed to be added there. Or, of course, one could create a plugin with a custom smarty function that would be called inside the template, then you could have your own independant tweetback section.

The easier alternative could be to merge tweetbacks with comments. There you could hook into "fetchcomments" and merge the data structure with all existing tweetbacks. $eventData in this event hook should hold an array of all comments; you could use array_merge or something like that to append that data structure.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
mattsches
Regular
Posts: 440
Joined: Sat Nov 05, 2005 9:35 pm
Location: Wiesbaden, Germany
Contact:

Re: Tweetback-Plugin for s9y?

Post by mattsches »

garvinhicking wrote:The easier alternative could be to merge tweetbacks with comments. There you could hook into "fetchcomments" and merge the data structure with all existing tweetbacks. $eventData in this event hook should hold an array of all comments; you could use array_merge or something like that to append that data structure.
Garvin, I had the same idea just an hour ago :wink: Sometimes, the simplest solutions are the best. I implemented it with array_merge(), and it works as expected. Now I only have to put it all together, thanks.

- Mattsches
oliverg
Regular
Posts: 43
Joined: Sat Feb 24, 2007 12:34 pm
Contact:

Re: Tweetback-Plugin for s9y?

Post by oliverg »

Now I'll be moptivated to droppp off my ideas more often in this place ;)

I'm looking forward to the thingy being finished ;)
Post Reply