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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

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   1360 Views


Community Member, 44 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