Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Blog Module /

Discuss the Blog Module.

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

Related Posts


Go to End


4 Posts   3037 Views

Avatar
juneallison

Community Member, 110 Posts

20 July 2011 at 3:04am

Hi,

I'd like to add a sidebox to my blog that shows a few related posts. This sidebox would only be visible when you are viewing a single blog entry. I've figured out how to add the sidebox. What I need advice on is how to grab and display the related posts.

By related I am thinking this would look at the tags associated with the blog entry and then show titles and excerpts of the 3 most recent posts that contain 1 or more of the tags associated with the blog entry.

And suggestions or ideas would be great.

thank you!

Avatar
biapar

Forum Moderator, 435 Posts

30 July 2011 at 10:20pm

Have you had solved?

Avatar
juneallison

Community Member, 110 Posts

31 July 2011 at 1:14am

@biapar - Thanks for asking! No, I haven't figured this one out yet.

In another thread I saw a snippet of code that looks like this:

function LatestNews($num=5) {
return DataObject::get("ArticlePage", "Tags LIKE '%news%' ", "Date DESC", "", $num);
}

...which seems along the lines of what I need. But I am not sure how I would modify this to grab the first tag or the other tags associated with the post the user is currently viewing.

If you have any suggestions, that would be great. Thanks!

Avatar
Misagh

Community Member, 9 Posts

7 August 2016 at 2:50am

Hi,
i want to know how to use this snippet when we don't know that customer use an exactly tag or category?(the customers adds new tags everyday)
what we must use instead "%news%" ?!?