Foren

Hidden pages still visible in custom theme

Klaus Bachmaier, geändert vor 7 Jahren.

Hidden pages still visible in custom theme

Regular Member Beiträge: 223 Beitrittsdatum: 30.09.13 Neueste Beiträge
I'm working on a custom theme, which originally was created by another developer. Now it appaears that pages show up in the navigation bar, even if they are marked as "Hide from Navigation Menu".

I know that the navigation is assembled in navigation.ftl, which works on a collection called nav_items, which gets set in the init.ftl.

In init.ftl I found this:


<#if navItems??>
	<#assign nav_items = navItems />
	<#assign has_navigation = (nav_items?size > 0) />
<!--#if-->


But where does the navItems collection come from? From what I saw yet, there is no further visibility check on nav_items, so I guess that navItems should only contain visible Layouts, right? So my problem must be while setting up the navItem collection, and I can't track where in the code this may be.
thumbnail
Olaf Kock, geändert vor 7 Jahren.

RE: Hidden pages still visible in custom theme

Liferay Legend Beiträge: 6400 Beitrittsdatum: 23.09.08 Neueste Beiträge
Klaus Bachmaier:
But where does the navItems collection come from?


You're probably looking for TemplateContextHelper. Or - as you see there: NavItems.fromLayouts(...)
Klaus Bachmaier, geändert vor 7 Jahren.

RE: Hidden pages still visible in custom theme

Regular Member Beiträge: 223 Beitrittsdatum: 30.09.13 Neueste Beiträge
Thanks Olaf!

Very strange as my problem is clearly related to the theme. When I switch to "classic" everything works as expected, so the cause must be somewhere in my theme files. Can't imagine that a portal class causes the trouble. Maybe I'm overlooking some kind of visibility check in the template files, and navItems should always contain all the layouts, even if invisible?

NavItems.fromLayouts(...) has a parameter layouts, which is set this way:

List<Layout> layouts = themeDisplay.getLayouts();

Can't dig deeper, because themeDisplay getLayouts() is just a property getter method. Anyway: As said above, the problem must be in the theme itself, not in themeDisplay
thumbnail
Olaf Kock, geändert vor 7 Jahren.

RE: Hidden pages still visible in custom theme

Liferay Legend Beiträge: 6400 Beitrittsdatum: 23.09.08 Neueste Beiträge
Well, the only call to the corresponding setter is in the ServicePreAction. Check the initialization and usage of layouts further up in that method - that might clarify a bit. Not sure about the difference between different themes though. Are they using the same navigation.vm (or .ftl) ?
Klaus Bachmaier, geändert vor 7 Jahren.

RE: Hidden pages still visible in custom theme (Antwort)

Regular Member Beiträge: 223 Beitrittsdatum: 30.09.13 Neueste Beiträge
Problem was in portal_main.ftl of the Theme.

Was:


&lt;#if nav_site_id?has_content&gt;
	 &lt;#assign all_layouts = layoutLocalService.getLayouts(nav_site_id?number, layout.isPrivateLayout())&gt;
&lt;#else&gt;
         &lt;#assign all_layouts = layoutLocalService.getLayouts(group_root_id, layout.isPrivateLayout())&gt;
<!--#if-->


But should have been:


&lt;#if nav_site_id?has_content&gt;
   &lt;#assign all_layouts = layoutLocalService.getLayouts(nav_site_id?number, true)&gt;
&lt;#else&gt;
     &lt;#assign all_layouts = layoutLocalService.getLayouts(group_root_id, layout.isPrivateLayout())&gt;
<!--#if-->


This change was made, because we need to show the Navigation of the "Main" Website, even if we show a completely different website.