Jump to:

23456 Posts in 18905 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » [Solved] How to get related articles?

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 577 Views
  • MitraX
    Avatar
    Community Member
    20 Posts

    [Solved] How to get related articles? Link to this post

    Hi,

    I'm trying to solve the problem with related articles based on MetaKeywords in v2.4, but without success.

    For example, the page SilverStripe Tips and Tricks (class BlogPostPage) has related articles below the content but they're manually added. What I want is to display automatically related articles that contain tags (i.e. MetaKeywords) as this particular page (e.g. silverstripe, cms, framework, tips tricks...). MetaKeywords are displayed as Tags section in the right column.

    I enabled the fulltext search feature and tried with the following code but it returns ALL articles on the site no metter whether they contain similar keywords or not:

    DataObject::get(
       "BlogPostPage",
       "MATCH (MetaKeywords) AGAINST ('$this->MetaKeywords' IN BOOLEAN MODE)"
    );

    as well as

    DataObject::get(
       "BlogPostPage",
       "MATCH (Title, MenuTitle, Content, MetaTitle, MetaDescription, MetaKeywords) AGAINST ('$this->MetaKeywords')"
    );

    Does anybode have any idea?

    Thanks

  • MitraX
    Avatar
    Community Member
    20 Posts

    Re: [Solved] How to get related articles? Link to this post

    Finally, I've solved the problem and implemented on my blog.

    Not only that the logic I created returns related articles based on tags (i.e. MetaKeywords) but it returns them by relevance! For example, if you visit funny article about jobs I dream of, you can notice that the first result has in common more than one tags and all below have only one.

    It's late here in Serbia and I need to "clean" existing articles from manually added related links in order to avoid duplicating results with new logic. So I'm going to create detail tutorial with code tomorrow and let you know.

  • MitraX
    Avatar
    Community Member
    20 Posts

    Re: [Solved] How to get related articles? Link to this post

    As I promised, here is the tutorial for getting related articles based on keywords.

    577 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.