Hello,
I was searching the forum for few hours but couldn’t find the solution for my problem..
I need a snippet code that will check if current selected menu has active child, if it has, I need to return menu name, if doesn’t, I have to return empty string.
Thank you!
now the code I have is:
<?php
$id = isset($id)? $id: $modx->documentObject[’id’];
$field = isset($field)? $field : "pagetitle";
$result = $modx->getDocument($id,$field);
return $result[$field];
?>
It returns all the page titles.
-
☆ A M B ☆
- 24,524 Posts
Solved with the next code:
<?php
$id = isset($id)? $id: $modx->documentObject[’id’];
$field = isset($field)? $field : "pagetitle";
$result = $modx->getDocument($id,$field);
$resu = $modx->getActiveChildren2($id);
if(count($resu))
{
return $result[$field];
}
else
{
return ’’;
}
?>
and this code add style display none inside the div
<?php
$id = isset($id)? $id: $modx->documentObject[’id’];
$field = isset($field)? $field : "pagetitle";
$result = $modx->getDocument($id,$field);
$resu = $modx->getActiveChildren2($id);
if(count($resu))
{
return ’’;
}
else
{
return ’style="display:none;"’;
}
?>
-
☆ A M B ☆
- 24,524 Posts
It helps if you use the forum’s code tags to enclose code; it’s the # button.