Skip to content

Commit

Permalink
Merge pull request #418 from jockri/fix-structure-node-in-tree
Browse files Browse the repository at this point in the history
[NodeBundle] Fix online/offline indication in the menu tree for child pages of structure nodes
  • Loading branch information
krispypen committed May 20, 2015
2 parents f837b97 + 1bd75f8 commit 5c6f00e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% set nodeId = menuitem.uniqueId %}

<li id="{{ nodeId }}"{% if menuitem.offline %} data-jstree='{"type":"offline"}'{% endif %} class="{% if menuitem.active or nodeId == 'node-1' %}jstree-open{% endif %}{% if menuitem.offline %} jstree-node--offline{% endif %}"{% if menuitem.role %} rel="{{menuitem.role}}"{% endif %}>
{% if menuitem.route %}
<a href="{{ path(menuitem.route, menuitem.routeparams) }}" class="{% if currentMenuItem is not null and currentMenuItem.uniqueId == menuitem.uniqueId %}active{% endif %}">
Expand Down
22 changes: 21 additions & 1 deletion src/Kunstmaan/NodeBundle/Helper/Menu/PageMenuAdaptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Kunstmaan\AdminBundle\Helper\Menu\TopMenuItem;
use Kunstmaan\NodeBundle\Entity\HideFromNodeTreeInterface;
use Kunstmaan\NodeBundle\Entity\Node;
use Kunstmaan\NodeBundle\Entity\StructureNode;
use Kunstmaan\NodeBundle\Helper\NodeMenuItem;
use Symfony\Component\HttpFoundation\Request;

Expand Down Expand Up @@ -144,6 +145,25 @@ private function isHiddenFromNodeTree($refEntityName)
return $isHidden;
}

/**
* Determine if current node is a structure node.
*
* @param string $refEntityName
*
* @return bool
*/
private function isStructureNode($refEntityName)
{
$structureNode = false;
if (class_exists($refEntityName)) {
$page = new $refEntityName();
$structureNode = ($page instanceof StructureNode);
unset($page);
}

return $structureNode;
}

/**
* Get an array with the id's off all nodes in the tree that should be expanded.
*
Expand Down Expand Up @@ -191,7 +211,7 @@ private function processNodes(
->setUniqueId('node-' . $child['id'])
->setLabel($child['title'])
->setParent($parent)
->setOffline(!$child['online'])
->setOffline(!$child['online'] && !$this->isStructureNode($child['ref_entity_name']))
->setRole('page')
->setWeight($child['weight']);

Expand Down

0 comments on commit 5c6f00e

Please sign in to comment.