Related Entries Plugin

Creating and modifying plugins.
Post Reply
Cenic
Regular
Posts: 20
Joined: Wed Jul 16, 2008 11:09 am

Related Entries Plugin

Post by Cenic »

Hi,

I have seen a number of blogs where a related articles section was below every entry. As far as I found out there is nothing similar for Serendipity. So here is the first release of a plugin I wrote.

The plugin uses the tags created by the freetags plugin to connect articles to each other. If two articles have common tags then they classify as related. So if you publish an article tagged as 'Foo' and 'Bar' then other entries with either the tag 'Foo' or 'Bar' are candidates to be shown in the list. Entries that have the tags 'Foo' and 'Bar' are even more likely to be shown. The is a configuration option to limit the number of links to show.

I thought about using the entry category as well but haven't implemented that yet.

A word of caution: this is the first time I created a plugin, so I'm not sure if this is working in all cases. Especially the way the plugin generates the output (by adding code to $eventData['display_dat']) might not be the proper way. I wanted to have the output between the entry and trackbacks/comments and this gave the best results. I'm using a custom template so there might be issues with the template as well.

Download: serendipity_event_related.zip

Comments and fixes by s9y hackers welcome!

Regards,
Stefan
If Java had true garbage collection, most programs would delete themselves upon execution. (Robert Sewell)
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Related Entries Plugin

Post by Don Chambers »

The freetag plugin already has an option to display related entries.
=Don=
Cenic
Regular
Posts: 20
Joined: Wed Jul 16, 2008 11:09 am

Re: Related Entries Plugin

Post by Cenic »

Now this is embarrassing... :oops: The formatting is not exactly what I want but I'll start playing with CSS for that. Sorry...
If Java had true garbage collection, most programs would delete themselves upon execution. (Robert Sewell)
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Related Entries Plugin

Post by yellowled »

Cenic wrote:The formatting is not exactly what I want
Recent versions of that plugin have an option to customize the emitted HTML code.

YL
Cenic
Regular
Posts: 20
Joined: Wed Jul 16, 2008 11:09 am

Re: Related Entries Plugin

Post by Cenic »

It works. With a change to my entries.tpl I was able to display the list of tags and the related links in different places of the page.

Thanks,
Stefan
If Java had true garbage collection, most programs would delete themselves upon execution. (Robert Sewell)
onli
Regular
Posts: 3043
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Related Entries Plugin

Post by onli »

Good to hear that :)
Don't be too disappointed you oversaw the existing functionality, your plugin seems like quite a solid work, it should help you when you build the next one.

If you have a look at the freetag-plugin (and there at the function addRelatedEntries), you could compare how the output is done there (via addfooter or as extension to eventData[$entry]).
Post Reply