Welcome Guest, Not a member yet? Register   Sign In
Implementing "Related posts" in CI?
#1

[eluser]aquary[/eluser]
My website was made entirely from CI, including blogs and forums. Right now I select related content manually, which is too boring. So I'm looking for a way to automatically generate "Related posts" somewhere in the sidebar but couldn't figure out how to do it yet.

For blogs, I'm thinking about using tags to determined which blogs are related. But right now I'm storing tags as a single string: "tag1, tag2, tag3", for using it as a page keywords only....

Any ideas are welcome :lol:
#2

[eluser]jedd[/eluser]
[quote author="aquary" date="1248871040"]
For blogs, I'm thinking about using tags to determined which blogs are related. But right now I'm storing tags as a single string: "tag1, tag2, tag3", for using it as a page keywords only....[/quote]

As you've no doubt discovered, this is a pretty painful way of doing it.

You want to have a table that connects your blogs to your tags. It'd probably be called blog_tag. You would then have a tag table that lists all your available tags. You'd need some code that lets you manage (CRUD) your tag table, as well as manage the links (CRUD for blog_tag).

Your tag table would be quite simple:
Code:
id        SERIAL
tag      CHAR(27)

Your blog_tag would be comparably simple:
Code:
id           SERIAL
blog_id    BIG INT UNSIGNED           # fk to your current blog.id
tag_id     BIG INT UNSIGNED            # fk to tag.id

You'd have blog_id and tag_id as INDEX

Complexity arises if you want to share tags between other entities than blogs - you hint that you might want to use the same tagging system for forum threads too?
#3

[eluser]aquary[/eluser]
[quote author="jedd" date="1248886721"]
As you've no doubt discovered, this is a pretty painful way of doing it.
[/quote]

At that time, I'm too lazy to think of a way to do it properly. Maybe I should remake the system again Smile

About using tags with forums, if it is not too difficult to implement, I'd like to do so. However, almost none of forum members would fill in the tags for their threads anyway...




Theme © iAndrew 2016 - Forum software by © MyBB