kputh
I'm new here

How can #nav.hasSubFolders be false across three levels of site structure?

Hi,

I'm using the format template below to generate an interactive menu in two projects. In one project, it works fine. In the other, it generates three levels of menu items – as it should – but #nav.hasSubFolders seems always to be false, which is wrong and breaks the menu. Can you give me advice on what my problem is, and how to fix it? Thank you.

Sincerely,

Kai

<CMS_HEADER>

    <CMS_FUNCTION name="Navigation" resultname="nav">

        <CMS_PARAM name="expansionVisibility" value="all" />

        <CMS_ARRAY_PARAM name="beginHTML">

            <CMS_ARRAY_ELEMENT index="0..2"><![CDATA[

                $CMS_IF(#nav.isFirst)$

                <ul class="accordion"

                    $CMS_IF(#nav.hasSubFolders && #nav.level < 2)$ data-accordion="menu-level-$CMS_VALUE(#nav.level)$" $CMS_END_IF$

                    role="tablist">

                $CMS_END_IF$

                <li class="accordion-navigation">

            ]]></CMS_ARRAY_ELEMENT>

        </CMS_ARRAY_PARAM>

        <CMS_ARRAY_PARAM name="endHTML">

            <CMS_ARRAY_ELEMENT index="0..2"><![CDATA[

                </li>

                $CMS_IF(#nav.isLast)$

                </ul>

                $CMS_END_IF$

            ]]></CMS_ARRAY_ELEMENT>

        </CMS_ARRAY_PARAM>

        <CMS_ARRAY_PARAM name="unselectedHTML">

            <CMS_ARRAY_ELEMENT index="0..2"><![CDATA[

                $CMS_IF(#nav.hasSubFolders && #nav.level < 2)$

                <a href="#menu-item-$CMS_VALUE(#nav.id)$" role="tab" id="menu-item-$CMS_VALUE(#nav.id)$-heading"

                   aria-controls="$CMS_VALUE(#nav.label.convert2)$">

                    $CMS_VALUE(#nav.label.convert2)$

                    <i class="fa fa-plus" aria-hidden="true"></i>

                    <i class="fa fa-minus" aria-hidden="true"></i>

                </a>

                $CMS_ELSE$

                <a href="$CMS_REF(#nav.ref)$">$CMS_VALUE(#nav.label.convert2)$</a>

                $CMS_END_IF$

                ]]>

            </CMS_ARRAY_ELEMENT>

        </CMS_ARRAY_PARAM>

        <CMS_ARRAY_PARAM name="selectedHTML">

            <CMS_ARRAY_ELEMENT index="0..2"><![CDATA[

                $CMS_IF(#nav.hasSubFolders && #nav.level < 2)$

                <a href="#menu-item-$CMS_VALUE(#nav.id)$" role="tab" id="menu-item-$CMS_VALUE(#nav.id)$-heading"

                   aria-controls="$CMS_VALUE(#nav.label.convert2)$">

                    $CMS_VALUE(#nav.label.convert2)$

                    <i class="fa fa-plus" aria-hidden="true"></i>

                    <i class="fa fa-minus" aria-hidden="true"></i>

                </a>

                $CMS_ELSE$

                <a href="$CMS_REF(#nav.ref)$">$CMS_VALUE(#nav.label.convert2)$</a>

                $CMS_END_IF$

                ]]>

            </CMS_ARRAY_ELEMENT>

        </CMS_ARRAY_PARAM>

        <CMS_ARRAY_PARAM name="innerBeginHTML">

            <CMS_ARRAY_ELEMENT index="0..1"><![CDATA[

                <div id="menu-item-$CMS_VALUE(#nav.id)$" class="content" role="tabpanel"

                     aria-labelledby="menu-item-$CMS_VALUE(#nav.id)$-heading">

            ]]></CMS_ARRAY_ELEMENT>

        </CMS_ARRAY_PARAM>

        <CMS_ARRAY_PARAM name="innerEndHTML">

            <CMS_ARRAY_ELEMENT index="0..1"><![CDATA[</div>]]></CMS_ARRAY_ELEMENT>

        </CMS_ARRAY_PARAM>

    </CMS_FUNCTION>

</CMS_HEADER>

$CMS_IF(!nav.isEmpty)$

    $CMS_VALUE(nav)$

$CMS_END_IF$

0 Kudos
8 Replies
rednoss
I'm new here

Hello Kai,

I've tested your navigation function inside the Mithras Energy standard project and #nav.hasSubFolders works as expected. Which FirstSpirit Version do you use? I guess you are using a framework for your interactive menu. Can you describe the expected behaviour and look of your navigation?

Best regards

Rene

0 Kudos

Hello Rene,

I use FirstSpirit 5.1.

The error occurs in a template for a hamburger menu and in another one for breadcrumbs. The hamburger menu should only contain the three or four top-most levels of site structure. Each item in the menu should be 'menu level'/site structure folder. If a folder has sub-folders, its menu item should be expandable with a click. (Like an accordion with more than one level.)

Sincerely,

Kai

0 Kudos

Hi Kai,

regarding its functionality in one and failure in the other project I wonder what the differences in the projects might be.

Can you give us an overview of the differences between the two projects?

Are the templates equal in both projects? No typo e.g.? Do you use feature transport for transfer of the templates?

You say that it seems that #nav.hasSubFolders is always false. Try outputting it to HTML for debugging (are you able to use the Template Debugger?).

I know of issues when the contents are not visible. I haven't had a failure on the Boolean itself yet.

Curious to hear from you,

Tibor

0 Kudos

Hi Tibor,

we develop templates in a development project, where the menu and breadcrumbs are correctly generated. Then the templates are exported/imported via feature transport into a testing and staging project, where #nav.hasSubFolders yields unexpected results. The content in both projects originates in a third project, both projects have different version of the content, and it is edited in the testing/staging project for testing purposes.

I just had a look at the breadcrumbs again and realized two things:

  1. there is an algorithmic error in the template that causes it to skip the lowest-level of structure nodes. This is a very prominent error, as we have many "shallow" top-level structure folders.
  2. in all other cases I can find, there are folders configured to appear in the menu with ancestor-folders configured to not appear in the menu.

So #nav.hasSubFolders seems to work correctly for the breadcrumbs. I need to examine the menu again with that in mind.

I never got to use the template debugger.

Sincerely,

Kai

0 Kudos

Hi there,

so maybe we misunderstood each other:

- did you check whether the boolean value is correct? It returns true whenever there is a subfolder. It doesn't take visibility checkboxes (content page or structure/menu) into account.

- regarding lowest level: did you try working with the root parameter instead? We use this to manage multiple sites in the same project.

Still there seems to be no reason why the above code shouldn't work as expected. Do you use an approval workflow? Are all related structures and contents approved?

0 Kudos

Hi Tibor,

I didn't check it this thoroughly.

And I see no advantage in using the root parameter. The breadcrumbs and menu are currently build from the intended root structure node, and I fixed the algorithmic error that caused the omission of the last level of structure folders.

Sincerely,

Kai

0 Kudos

Hey,

I see. It wasn't quite clear to me if you still have a problem with the algorithm or not.

Let me know if you find a reason for the menu behavior.

Sincerely,

Tibor

0 Kudos
STrojette
Returning Observer

Sorry the necro, but this issue still isn't fixed in the product.

Maybe some of you like to support my Feature Request?

https://community.crownpeak.com/t5/Feature-Discussions/New-nav-hasVisibleSubFolders-Function/idi-p/5...

0 Kudos