2.1. M2_Content_Util

M2_Content_Util::hier2ul($hier, $options)

This will take the output from M2_Content::getTree() and turn it into an unordered HTML list (<ul>) suitable for creating a navigation or any other hierarchical representation of the data.

All nodes on the tree will be turned into HTML links, with a few exceptions, described in the options table.

$hier is the M2_Content::getTree() output, and the $options are described below:

Table 29. Options for M2_Content_Util::hier2ul

OptionDescription
rootClass

A HTML class added to the root <ul> element

currentNodeID

The ID of the current node. If set, this node will not be an HTML link.

urlField

The field in the type that should be used to generate the URL for the link. You must choose between using this option, or the urlTemplate below.

titleField

The field in the type that should be used to generate the anchor text.

urlPrefix

A string to prefix all links.

urlTemplate

A template to generate the links, in which you can use the placeholder [ID] to be translated into the node ID.

type

One of the following:

  • ul-basic: Will output a list where all nodes are attached

  • ul-narrow: Will output a list where only the trail to the selected (currentNodeID) is "open" in the list. This means that leafs on the root node will only contain children if the current node is between the descendants.

firstRootIsFrontpage

For CMS purposes. If set to TRUE, the first node at root level will get the link "/".

parentsAreEmptyLinks

For CMS purposes. If set to TRUE, all nodes containing child nodes will have a URL of "#".