Jump to:

1835 Posts in 1139 Topics by 554 members

Blog Module

SilverStripe Forums » Blog Module » [SOLVED]Pull latest blog post except the one that is currently viewed. Please Help.

Discuss the Blog Module.

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

Page: 1 2 3
Go to End
Author Topic: 2023 Views
  • Pigeon
    Avatar
    Community Member
    243 Posts

    Re: [SOLVED]Pull latest blog post except the one that is currently viewed. Please Help. Link to this post

    Hi Juan,

    This sounds like something to do with versioning.

    There may not be an entry in BlogEntry_Live with ID 739, but that is because the IDs of the *_Live tables aren't 1-1 with the IDs in the draft tables. Instead, RecordID is used in the *_Live tables.

    Versioning should take care of this for you with your DO::get() queries, so, is the blog post you're trying to filter published?

    If it isn't, publish it or view the site as draft mode.

    If it is, then try BlogEntry.RecordID != xxx

    If that still isn't working, make sure your site is in 'dev' mode, then add a 'die;' imediately after the DO::get() that isn't working and add '?showqueries' to the end of the url, this will print out all the SQL queries that are run. Then copy the LAST query on the page, save it into a txt file and upload it as an attachment with the next post you leave here.

    Dan

  • Juan
    Avatar
    Community Member
    18 Posts

    Re: [SOLVED]Pull latest blog post except the one that is currently viewed. Please Help. Link to this post

    now its working..

    what i did is i concatenate the ID into the URL. $link?blogid=$ID

    return FeedAggregator::posts_by_sport($sportHolder,10, $_GET['blogid']);

    and using this query

    $posts = DataObject::get('BlogEntry','ParentID IN('.$idList.') AND "BlogEntry".ID != '. (int) $postID,'Date DESC','',$limit);

    thank you guys!

    2023 Views
Page: 1 2 3
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.