get the _children of a linked page

11 views
Skip to first unread message

Peter Shaw

unread,
Sep 23, 2016, 10:35:35 AM9/23/16
to apostr...@googlegroups.com
Hi community, Hi Tom 

Why the ittem array of a  joinByOne’s apostrophe-page does not contain it’s children? 

What i got is this widget:
 
module.exports = {
  extend: 'apostrophe-widgets',
  label: 'Interner Link',
  addFields: [
    {
      name: '_page',
      type: 'joinByOne',
      withType: 'apostrophe-page',
      label: 'Page',
      idField: 'pageId'
    }   
 ]
};

I have to display all children (1st level) underneath it. 

I store the page-link in my global scope invisible: 
{{
apos.singleton(data.global, 'applicationpage', 'adt-innerlink-li', {
visible: false
})
}}     

Just to get it for a link list: 
{% for tab in data.global.applicationpage.items.pop()._page._children %}
<li><a href="{{ tab._url }}">{{ tab.title }}</a></li>
{% endfor %}

But even when the page object has children, the data.global.applicationpage items does not.
I loged data.global.applicationpage:

{ type: 'area',
  items: 
   [ { _id: 'w835494927120381536',
       pageId: 'citfnn3aq00033gbj6v4yc5ee',
       type: 'adt-innerlink-li',
       _edit: true,
       _page: [Object] } ],
  _edit: true,
  _docId: 'citfllqhl0005tnbjpq9cw3ak',
  _dotPath: 'applicationpage’ }


and diged into item_page: ( data.global.applicationpage.items[0]._page ) 

{ _id: 'citfnn3aq00033gbj6v4yc5ee',
  published: true,
  loginRequired: '',
  trash: false,
  type: 'default',
  title: 'Anwendungen',
  slug: '/anwendungen',
  tags: [],
  orphan: false,
  viewUsersIds: [],
  viewGroupsIds: [],
  editUsersIds: [],
  editGroupsIds: [],
  rank: 1,
  path: '/anwendungen',
  level: 1,
  createdAt: Fri Sep 23 2016 12:59:02 GMT+0200 (CEST),
  titleSortified: 'anwendungen',
  updatedAt: Fri Sep 23 2016 12:59:02 GMT+0200 (CEST),
  highSearchText: 'anwendungen anwendungen',
  highSearchWords: [ 'anwendungen' ],
  lowSearchText: 'anwendungen anwendungen',
  searchSummary: '',
  docPermissions: [],
  _edit: true,
  _publish: true,
  _url: '/anwendungen’ }

no _children array exists. 

When I log data.page on this page it has children: 
{ _id: 'citfnn3aq00033gbj6v4yc5ee',
  published: true,
  loginRequired: '',
  trash: false,
  type: 'default',
  title: 'Anwendungen',
  slug: '/anwendungen',
  tags: [],
  orphan: false,
  viewUsersIds: [],
  viewGroupsIds: [],
  editUsersIds: [],
  editGroupsIds: [],
  rank: 1,
  path: '/anwendungen',
  level: 1,
  createdAt: Fri Sep 23 2016 12:59:02 GMT+0200 (CEST),
  titleSortified: 'anwendungen',
  updatedAt: Fri Sep 23 2016 12:59:02 GMT+0200 (CEST),
  highSearchText: 'anwendungen anwendungen',
  highSearchWords: [ 'anwendungen' ],
  lowSearchText: 'anwendungen anwendungen',
  searchSummary: '',
  docPermissions: [],
  _edit: true,
  _publish: true,
  _url: '/anwendungen',
  _ancestors: 
   [ { ... } ],
  _children
   [ { _id: 'citfp16td0003i5bjhh6r9we7',
       published: true,
       loginRequired: '',
       trash: false,
       type: 'default',
       title: 'Inspector Json',
       slug: '/anwendungen/inspector-json',
       viewUsersIds: [],
       viewGroupsIds: [],
       editUsersIds: [],
       editGroupsIds: [],
       tags: [],
       orphan: false,
       rank: 0,
       path: '/anwendungen/inspector-json',
       level: 2,
       createdAt: Fri Sep 23 2016 13:38:00 GMT+0200 (CEST),
       titleSortified: 'inspector json',
       updatedAt: Fri Sep 23 2016 13:38:00 GMT+0200 (CEST),
       highSearchText: 'inspector json anwendungen inspector json',
       highSearchWords: [Object],
       lowSearchText: 'inspector json anwendungen inspector json',
       searchSummary: '',
       docPermissions: [],
       _edit: true,
       _publish: true,
       _url: '/anwendungen/inspector-json',
       _children: [] } ] }


Does anyone know how to geht the children with a joinByOne’s apostrophe-page? Or how to load the page by it’s id that I can get the children's attributes?


Thanks a lot, 
ps


Tom Boutell

unread,
Sep 26, 2016, 10:18:57 AM9/26/16
to apostr...@googlegroups.com
Hi Peter,

Fetching subpages is something that happens because the page serving
route elects to call those cursor filters. They take extra time and do
extra work, and most joins don't need them, so we usually prefer to
avoid "paying" for them.

But, you can turn on extra cursor filters yourself in any join:

addFields: [
{
name: '_page',
type: 'joinByOne',
withType: 'apostrophe-page',
label: 'Page',
idField: 'pageId',
filters: {
children: true
}
}
]

That should do the trick for you!

By default this join will load areas on the page you're joining with.
For speed, you might want to eliminate that:

filters: {
areas: false
}

Or restrict it:

filters: {
areas: [ 'thumbnail' ]
}

By default the cursor that fetches the children won't fetch areas, so
you won't get thumbnails etc. for them. But if you pass an object to
"children" you can set filters for that cursor too:

filters: {
children: {
areas: [ 'thumbnail' ]
},
}

Hope this speeds you on your way!
> --
> You received this message because you are subscribed to the Google Groups
> "apostrophenow" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to apostropheno...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--


THOMAS BOUTELL, SUPPORT LEAD
P'UNK AVENUE | (215) 755-1330 | punkave.com

Peter Shaw

unread,
Sep 27, 2016, 11:19:16 AM9/27/16
to apostrophenow
Hi Tom. 

Thanks a lot, that works wonderful for me. Things getting clear by your explanation. 
wonderful! 

Have a nice day, 
ps
Reply all
Reply to author
Forward
0 new messages