Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » Problem auto-detecting Page or Page_Live

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1094 Views
  • blueskies
    Community Member
    42 Posts

    Problem auto-detecting Page or Page_Live Link to this post

    Hi all,

    I've been busy with this little gem for a while now and can't find any leads anywhere, so I'm hoping someone can point me in the right direction. In a ProductPage_Controller class I have the following custom function:

    function OtherProducts() {
          return DataObject::get("ProductPage", "ParentID = {$this->ParentID} AND ProductPage.ID!={$this->ID}", "Created ASC", "","5");      

    This returns all ProductPages under the current parent excluding the current page (in other words: all _other_ pages under this parent).

    The problem is that ProductPage.ID, of course, gives an error (unknown column) when working with Live data, because it should be ProductPage_Live.ID. I can't find any way to (preferably) stick a variable in it so it can determine auto-magically whether it should be ProductPage or ProductPage_Live table.

    P.S. I can't just make it ID!={$this->ID} because then it throws an error that the ID field is ambiguous....

  • Fuzz10
    Community Member
    787 Posts
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.