Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Problems with Navigation - dont show item if content is empty


Go to End


14 Posts   1911 Views

Avatar
BBS

Community Member, 7 Posts

7 March 2017 at 1:07am

Edited: 07/03/2017 1:09am

Hey i'm completely new to SilverStripe CMS
my customer use SilverStripe and have wish.
Sorry for my bad english. i'm german.
a sub-menu must be dont appear if the content of the sub-menu point is empty.
how can i realize that ?
if found the code part in the template:

				<div id="navigation-menue" role="navigation"<% if ClassName == "WBBStartPage" %> class="start"<% end_if %>>
					<ul id="navigation-menue-list">
<% control Menu(1) %>
						<li class="$LinkingMode<% if Children %> has-childs<% end_if %>">
							<a href="$Link" class="din" title="$Title.XML">$MenuTitle.XML</a>
	<% if Children %>
							<ul>
		<% control Children %>
				<li><a href="$Link" class="din" title="$MenuTitle.XML">$MenuTitle</a></li>
		<% end_control %>
							</ul>
	<% end_if %>
						</li>
<% end_control %>
					</ul>
				</div>

how can i say that "<li><a href="$Link" class="din" title="$MenuTitle.XML">$MenuTitle</a></li>" just appear if the content of that page is not empty?

i hope anybody can help me

thanks in advance

Avatar
martimiz

Forum Moderator, 1391 Posts

7 March 2017 at 2:17am

I'm not sure I understand correctly. Why would you have empty pages on the website at all? Why not remove them from the CMS if they are empty?

You can for instance check if the 'Content' field on the page is empty by doing:

<% control Children %>
	<% if $Content %>
		<li><a href="$Link" class="din" title="$MenuTitle.XML">$MenuTitle</a></li>
	<% end_if %>
<% end_control %>

If it's an old version of SilverStripe you might have to write <% if Content %> instead of <% if $Content %>

But otherwise it's hard to tell from here - you could give us a link to such an empty page situation...

Avatar
BBS

Community Member, 7 Posts

7 March 2017 at 3:47am

thank you for your replay.
its about this Site
the right nav-item "Kennzahlen" has no content!
i want, if the right nav-item has no content that the nav-item will not show in the nav-list, it must be invisible.
it's version 2.4.5
i've try :

				<div id="navigation-menue" role="navigation"<% if ClassName == "WBBStartPage" %> class="start"<% end_if %>>
					<ul id="navigation-menue-list">
<% control Menu(1) %>
						<li class="$LinkingMode<% if Children %> has-childs<% end_if %>">
							<a href="$Link" class="din" title="$Title.XML">$MenuTitle.XML</a>
	<% if Children %>
							<ul>
		<% control Children %>
				<% if Content %>
				<li><a href="$Link" class="din" title="$MenuTitle.XML">$MenuTitle</a></li>
				<% end_if %>
		<% end_control %>
							</ul>
	<% end_if %>
						</li>
<% end_control %>
					</ul>
				</div>

but this dont work :-(

Avatar
martimiz

Forum Moderator, 1391 Posts

7 March 2017 at 4:19am

Ok - first of all: in version 2.4.x I think you need to flush the cache after changing the template, before you can see the changes:

- login on the CMS
- call the url http://yoursite.xx?flush=all (takes a short while)

If this doesn't work, you need to find out why the page is empty by logging into the CMS and looking at the page. Probably the page is empty because the Content in the text editor of that page is empty. You need to check if it is really empty or if it has empty lines (they are content too!!!)

Then tell your customer that they need to unpublish pages that are empty or that shouldn't be displayed, because it is absolute nonsense - don't say that :) - to have empty pages on your website!

Note: if a page is unpublished, it is still visible in the CMS and on the concept site when the customer is logged in, but ordinary users won't see it and it will not appear in any menus. This is the way SilverStripe should be used - you shouldn't have to hack that in the template!!!

Avatar
BBS

Community Member, 7 Posts

7 March 2017 at 5:06am

i do flush, but nothing happens
if i go into the menu on the topbar there is
http://prntscr.com/egqbye -> Unternehmen
then i goto the "edit"
http://prntscr.com/egqc7a
and then
http://prntscr.com/egq8z6
then there is nothing to show

what do i wrong ?

Avatar
martimiz

Forum Moderator, 1391 Posts

7 March 2017 at 11:17am

Edited: 07/03/2017 11:19am

As far as I can see you're not doing anything wrong. There seems to be a lot of extra code and custom settings involved, so I can't really see what's going on. Maybe the texteditor is actually empty, but that doesn't tell me that this is the 'Content' field, which we were checking on. And I don't see a publish/unpublish button as well.

And I stick to what I said: if the page has no content it shouldn't be published at all, then you wouldn't have this problem.

But I don't think I can help you much further at this point, because I don't really know from here how this site is built. Maybe they/you could hire someone with SilverStripe knowledge to fix the site and give you a tour at the same time?

Avatar
BBS

Community Member, 7 Posts

8 March 2017 at 1:52am

how can i figured out if its the content field ? or how can i output the Content variable to see whats in there ?
or how can i find the php file who builds the nav ?

The Problem ist some company pages has content others not, thats the problem. if i unpublish the page, no page will show even if the companys page has content :/

Avatar
BBS

Community Member, 7 Posts

8 March 2017 at 2:04am

i found now the right ss file its SideOverview.ss, but if i insert the "If Content" Thing, the sidebar completely disappear... there are other variables they i can use ?

Go to Top