I had PrevJumpNext working but have now updated my site to 2.1.1 and it has stopped working.
A quick look and it seems getActiveChildren has been depreciated and removed and thats causing the problem.
I have read I can replace getActiveChildren with getCollection but how do I get it to return the same as getActiveChildren so the snippet will work again?
I have added
$children = modX->getCollection(’modResource’, $criteria);
but don’t know how to get the $criteria setup to create the required output.
Any help much appreciated.
thanks
J
From the original GetActiveChildren :-
$fields='id, pagetitle, description, parent, alias, menutitle, class_key, context_key';
$columns = explode(',', $fields);
foreach ($columns as $colKey => $column) $columns[$colKey] = trim($column);
$criteria = $this->newQuery('modResource');
$criteria->setClassAlias('sc');
$criteria->select('id');
$criteria->select($columns);
$criteria->where(array(
'sc.parent' => $id,
'sc.published' => '1',
'sc.deleted' => '0'
));
There may be a better way to do this now in the 2.1 API.
Use MODx, or the cat gets it!
Thanks for the quick response.
Is that the actual code from getactivechildren, or have you modified it to work.
I have tried implementing it by adding it to the prevjumpnext snippet but just get a blank page.
am I missing something?
Cheers
J
Its from the code base, so you need to set the $id, in the line ’sc.parent => $id’ substitute the id passed in the snippet for $id. I’ve not looked at the snippet itself but you should be able to blend this into it.
Use MODx, or the cat gets it!
Hi,
I have replaced
$children = $modx->getActiveChildren($startID, $sortBy, $sortHow, $fields);
with
$fields=’id, pagetitle, description, parent, alias, menutitle, class_key, context_key’;
$columns = explode(’,’, $fields);
foreach ($columns as $colKey => $column) $columns[$colKey] = trim($column);
$criteria = $this->newQuery(’modResource’);
$criteria->setClassAlias(’sc’);
$criteria->select(’id’);
$criteria->select($columns);
$criteria->where(array(
’sc.parent’ => $startID,
’sc.published’ => ’1’,
’sc.deleted’ => ’0’
));
$children = $modx->getCollection(’modResource’,$criteria);
But this just gives me a blank white page
If I comment out
//$children = $modx->getCollection(’modResource’,$criteria);
the page will display but the prevjumpnext function outputs no links
am I missing something, I have followed it through and it all seems to make sense
Cheers
J
The ’$criteria = $this-’ should be $modx, not $this, try that.
Use MODx, or the cat gets it!
Hi, Thanks for the suggestion,
have updated the $this to $modx but I am still getting a blank page when I remove the // from the line below
//$children = $modx->getCollection(’modResource’,$criteria);
is there a problem with getCollection, how would I check this?
Many Thanks
J