librelist archives

« back to archive

menu weirdness

menu weirdness

From:
Jeff Schoolcraft
Date:
2012-03-31 @ 22:01
I have a bit of nav code that looks like this:

%nav#nav-main.clear
   - display_menu(Nesta::Menu.full_menu)

A menu.txt (at content/menu.txt) that looks like:

/
services
   web-application-development
   ios-application-development
   project-rescue
   training
company
   products
   clients
   working-with-us
   how-we-work
portfolio
   freelance-funnel
   hubscovery
   meatspace-marketing
   urlagg
   math-minute-addition
   bddcasts
blog

and the rendered output (on localhost:9393/services) looks like:

<nav class='clear' id='nav-main'>
<ul>
<li>
<a href='http://localhost:9393/'></a>
</li>
<li class='current'>
<a href='http://localhost:9393/services'></a>
</li>
</ul>
</nav>

So, some questions.

1. Why am I only getting those 2 items?  At one point, only those 2 
items were there but I've made sure caching was turned off, and I've 
killed shotgun and restarted it.

2. Why aren't the page names being used as inner content to the anchor tags?

I've tried a bunch of variations:

%nav#nav-main.clear
   - display_menu(Nesta::Menu.top_level)

and

%nav#nav-main.clear
   - display_menu(@menu_items)

and

%nav#nav-main.clear
   - display_menu(Nesta::Menu.for_path("/company"))

(though admittedly here I get an error: undefined method `each' for 
nil:NilClass, which would make it seem that company didn't exist).

content/menu.txt is where the menu lives.

Any ideas?

Thanks,

Jeff

Re: [nesta] menu weirdness

From:
Graham Ashton
Date:
2012-04-01 @ 15:12
On 31 Mar 2012, at 23:01, Jeff Schoolcraft <jeff@thequeue.net> wrote:

> Why am I only getting those 2 items?

The third page referenced by your menu doesn't exist. Search this page for
the word "relative"; it's an important sentence:

http://nestacms.com/docs/creating-content/menus

In other words, sub menu items need specifying with their full paths.

Admittedly the example menu doesn't illustrate this well, as the paths in 
the example file don't look like they're relative to /.

I can't answer the other questions without pointing a debugger at it. Repo URL?

Re: [nesta] menu weirdness

From:
Jeff Schoolcraft
Date:
2012-04-01 @ 15:17
https://bitbucket.org/jschoolcraft/agilitum.com/

Graham Ashton wrote:
>
> On 31 Mar 2012, at 23:01, Jeff Schoolcraft<jeff@thequeue.net> wrote:
>
>>
>> Why am I only getting those 2 items?
>
>
> The third page referenced by your menu doesn't exist. Search this page 
> for the word "relative"; it's an important sentence:
>
> http://nestacms.com/docs/creating-content/menus
>
> In other words, sub menu items need specifying with their full paths.
>
> Admittedly the example menu doesn't illustrate this well, as the paths 
> in the example file don't look like they're relative to /.
>
> I can't answer the other questions without pointing a debugger at it. 
> Repo URL?

Re: [nesta] menu weirdness

From:
Graham Ashton
Date:
2012-04-02 @ 09:55
On 1 Apr 2012, at 16:17, Jeff Schoolcraft wrote:

> https://bitbucket.org/jschoolcraft/agilitum.com/

The menu item headings weren't showing up because the pages didn't have 
any headings. The title metadata doesn't set the page heading, just the 
title tag.

Do I need to make more of the statement "every web page should have a main
heading" on this page?

http://nestacms.com/docs/creating-content/pages

I notice it doesn't say what happens if you don't have one...

Re: [nesta] menu weirdness

From:
Jeff Schoolcraft
Date:
2012-04-02 @ 11:14
I'm using the title to set the h1 programmatically in the layout.

For example: 

https://bitbucket.org/jschoolcraft/agilitum.com/src/c67644cfadc5/views/full_width.haml#cl-5

or are we not talking about h1's and talking about metadata

Graham Ashton wrote:
>
> On 1 Apr 2012, at 16:17, Jeff Schoolcraft wrote:
>
>>
>> https://bitbucket.org/jschoolcraft/agilitum.com/
>
>
> The menu item headings weren't showing up because the pages didn't 
> have any headings. The title metadata doesn't set the page heading, 
> just the title tag.
>
> Do I need to make more of the statement "every web page should have a 
> main heading" on this page?
>
> http://nestacms.com/docs/creating-content/pages
>
> I notice it doesn't say what happens if you don't have one...

Re: [nesta] menu weirdness

From:
Graham Ashton
Date:
2012-04-02 @ 11:16
On 2 Apr 2012, at 12:14, Jeff Schoolcraft wrote:

> I'm using the title to set the h1 programmatically in the layout.
> 
> For example: 
https://bitbucket.org/jschoolcraft/agilitum.com/src/c67644cfadc5/views/full_width.haml#cl-5
> 
> or are we not talking about h1's and talking about metadata

Nesta parses the first line of the body of your document, expecting it to 
be a heading. It extracts the text and uses it in things like menus to 
link to the page.

There's a discussion on GitHub issue 104 about this, and a plan to add new
"Link text" metadata so that this becomes less magic and a bit more 
obvious.

Re: [nesta] menu weirdness

From:
Jeff Schoolcraft
Date:
2012-04-08 @ 16:26
I'm trying to wrap my head around menus, I understand your point about 
every page needing a heading (even though I had a heading in a layout 
set programmatically by title).

I went back through, killed everything and started with just pages and 
menu: https://bitbucket.org/jschoolcraft/agilitum.com

I'm still not getting what I expect.

I even did some poor man debugging in lib/models to see what was going 
on with menu:

MENU:
[]
MENU: Processing: /
MENU: current_depth: 0, :depth => 0
calling: sub_menu_for_depth(menu, 0) << page
calling: append_menu_item(menu, file, 0)
MENU:
[#<Nesta::Page:0x00000101d35520 @filename="content/pages/index.haml", 
@format=:haml, @metadata={}, @markup="- display_menu(@menu_items)\n\n- 
display_menu(Nesta::Menu.full_menu)\n\n%h1 Home\n\n%section.articles= 
article_summaries(latest_articles)\n", @mtime=2012-04-08 11:38:09 -0400>]
MENU: Processing: services
MENU: current_depth: 0, :depth => 0
calling: sub_menu_for_depth(menu, 0) << page
calling: append_menu_item(menu, file, 0)
MENU:
[#<Nesta::Page:0x00000101d35520 @filename="content/pages/index.haml", 
@format=:haml, @metadata={}, @markup="- display_menu(@menu_items)\n\n- 
display_menu(Nesta::Menu.full_menu)\n\n%h1 Home\n\n%section.articles= 
article_summaries(latest_articles)\n", @mtime=2012-04-08 11:38:09 
-0400>, #<Nesta::Page:0x00000101d236e0 
@filename="content/pages/services/index.haml", @format=:haml, 
@metadata={}, @markup="%h1 Services\n\n%h2 Foo\n\n%h2 Bar\n", 
@mtime=2012-04-08 09:09:39 -0400>]
MENU: Processing:   web-application-development
(it dies here, Page is nil)

I stepped through all the File.load code, and it can find 
web-application-development and looks like it should be able to load it 
if it isn't cached already.

Can you clue me in on what I'm doing wrong?  Every page that's in the 
menu exists, every page has a heading as the first line of body content.

> Graham Ashton <mailto:graham@effectif.com>
> April 2, 2012 7:16 AM
>
> Nesta parses the first line of the body of your document, expecting it 
> to be a heading. It extracts the text and uses it in things like menus 
> to link to the page.
>
> There's a discussion on GitHub issue 104 about this, and a plan to add 
> new "Link text" metadata so that this becomes less magic and a bit 
> more obvious.
> Jeff Schoolcraft <mailto:jeff@thequeue.net>
> April 2, 2012 7:14 AM
> I'm using the title to set the h1 programmatically in the layout.
>
> For example: 
> 
https://bitbucket.org/jschoolcraft/agilitum.com/src/c67644cfadc5/views/full_width.haml#cl-5
>
> or are we not talking about h1's and talking about metadata
>
> Graham Ashton wrote:
> Graham Ashton <mailto:graham@effectif.com>
> April 2, 2012 5:55 AM
>
> The menu item headings weren't showing up because the pages didn't 
> have any headings. The title metadata doesn't set the page heading, 
> just the title tag.
>
> Do I need to make more of the statement "every web page should have a 
> main heading" on this page?
>
> http://nestacms.com/docs/creating-content/pages
>
> I notice it doesn't say what happens if you don't have one...
> Jeff Schoolcraft <mailto:jeff@thequeue.net>
> April 1, 2012 11:17 AM
> https://bitbucket.org/jschoolcraft/agilitum.com/
>
> Graham Ashton wrote:
> Graham Ashton <mailto:graham@effectif.com>
> April 1, 2012 11:12 AM
>
> The third page referenced by your menu doesn't exist. Search this page 
> for the word "relative"; it's an important sentence:
>
> http://nestacms.com/docs/creating-content/menus
>
> In other words, sub menu items need specifying with their full paths.
>
> Admittedly the example menu doesn't illustrate this well, as the paths 
> in the example file don't look like they're relative to /.
>
> I can't answer the other questions without pointing a debugger at it. 
> Repo URL?

Re: [nesta] menu weirdness

From:
Max Sadrieh
Date:
2012-04-09 @ 21:19
Hi Jeff,

Would this help:

diff --git a/content/menu.txt b/content/menu.txt
index 9c5b8b3..b88dc13 100644
--- a/content/menu.txt
+++ b/content/menu.txt
@@ -1,9 +1,9 @@
 /
 services
-  web-application-development
-  mobile-application-development
-  project-rescue
-  training
+  services/web-application-development
+  services/mobile-application-development
+  services/project-rescue
+  services/training
 products
 company
-  how-we-work
+  company/how-we-work


You're final menu.txt is therefore https://gist.github.com/2346605

Your problem was that the pages (for example project-rescue) are in the
folders (for example services/) and the menu operates from
$NESTA_ROOT/content/

Cheers.

-Max Sadrieh