-
☆ A M B ☆
- 209 Posts
I had been given some PHP for a snippet on the forums a while back to assist me in submenus on the sidebar of pages with children resources. However, it no longer works in Revo 2.3. Can someone assist me in modifying it so it is 2.3 compatible?
Snippet:
<?php
$document = $modx->getObject('modResource', $id);
if($document){
return $document->hasChildren()? '1' : '0';
}
return '';
Use:
[[hasChildren:is=`1`:then=`getResources Call`]]
Ben Morrison
Hacking templates to pieces since 2003
-
☆ A M B ☆
- 24,524 Posts
It looks like it expects a property of &id with the ID of the parent.
discuss.answer
-
☆ A M B ☆
- 24,524 Posts
If you want the snippet to use the current resource's ID by default try this version
<?php
$id = $modx->getOption('id', $scriptProperties, $modx->resource->get('id'));
$document = $modx->getObject('modResource', $id);
if($document){
return $document->hasChildren()? '1' : '0';
}
return '';
That extra line says "get the option named 'id' - from the snippet's properties - by default use the current resource ID".
-
☆ A M B ☆
- 209 Posts
Ben Morrison
Hacking templates to pieces since 2003