2

Hi I m using elementapi plugin to create an json object from my elements. I would like to get all entries, but not those ones who have a children.

My criteria it looks like this now

'elementType' => 'Entry',
'criteria' => ['section' => ['pages', 'home']],
'transformer' => function (EntryModel $entry) {

this returns all entries. For example I have one single home and some other pages the result looks like this:

Home
About us <- this one has children
---------
test1
test2
test3
---------
Contact us

I would like to have result like this

Home
About us
Contact us

Is it possible to achieve this whit some criteria attribute. I've already tried to add level, like this

'criteria' => ['section'=>['pages','home'], 'level'=>'!=2' ]

not working

'criteria' => ['section'=>['pages','home'], 'level'=>1 ]

it's working but returns only pages not giving me the home section

I've tried hasChildren, hasDescendants none of this is working.

If someone can help, thank you in advance.

1 Answer 1

1

So after some rest, I did find the solution as follow:

'criteria' => ['section' => ['pages', 'home'], 'level'=>array(null,1)]

This gives me the desire result.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.