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.

Archive /

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

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

Problem auto-detecting Page or Page_Live

Go to End

2 Posts   1356 Views


Community Member, 43 Posts

10 April 2008 at 8:58pm

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....


Community Member, 791 Posts

11 April 2008 at 12:42am