Fórum

Hidden pages still visible in custom theme

Klaus Bachmaier, modificado 7 Anos atrás.

Hidden pages still visible in custom theme

Regular Member Postagens: 223 Data de Entrada: 30/09/13 Postagens Recentes
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, modificado 7 Anos atrás.

RE: Hidden pages still visible in custom theme

Liferay Legend Postagens: 6403 Data de Entrada: 23/09/08 Postagens Recentes
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, modificado 7 Anos atrás.

RE: Hidden pages still visible in custom theme

Regular Member Postagens: 223 Data de Entrada: 30/09/13 Postagens Recentes
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, modificado 7 Anos atrás.

RE: Hidden pages still visible in custom theme

Liferay Legend Postagens: 6403 Data de Entrada: 23/09/08 Postagens Recentes
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, modificado 7 Anos atrás.

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

Regular Member Postagens: 223 Data de Entrada: 30/09/13 Postagens Recentes
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.