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.

Data Model Questions /

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

Filtered dataobject by Parent

Go to End

2 Posts   539 Views


Community Member, 58 Posts

18 November 2012 at 2:03pm

Hi, I have
DataObject that is assigned to TownPage
I have a few TownPage Page on site.

Using this function i filtered dataobject by Status and Waznosc

function ListObiektsPaid() {
        $now = date('Y-m-d H:i:s');
        $where = "Created <= '$now' AND Waznosc > '$now'";

        return Dataobject::get('Obiekt', "Status='Oplacony' AND $where", 'Created DESC');

but in all townPage dataobject is show - I would also filtered by Parent ID.

The idea is that if DataObject is assigned to a specific town Page i want to just be there show

To TownPage are assigned DataObject by checkbox (tutorial from ssbits - dataobjects-as-pages-part-2)

Sorry for my bad English


Forum Moderator, 1203 Posts

19 November 2012 at 1:47am


If your ListObiectsPaid() function is part of your TownPage, you can either add this to your query: " AND TownPage_ID = ' $this->ID'" or filter the relation object directly. Example again on SSBits: