A bit of OO for a nice menu...
3 posts
• Page 1 of 1
A bit of OO for a nice menu...
I figured the best way to do the menu for a MI-app would be to use the ase-class that my pages inherit from and then do something like this:
The function ActiveIf should return the string class="active if the name of the linked class matches the name of the "currently active child-class" and then append the opening a-tag. The idea of checking ⎕INSTANCES only works as long as the other pages haven't been active, so I need another way to find the current instance of a class that called a fn in the base class it inherited from. Surely there must be an elegant way to do this, but I'm afraid I missed that bit... :((
∇ R←RenderMenu
R←'<ul>',nl
R,←' <li',(ActiveIf'Index'),'Home</a></li>',nl
R,←' <li',(ActiveIf'Fotos'),'Fotos</a></li>',nl
R,←' <li',(ActiveIf'Listen'),'Listen</a></li>',nl
R,←'</ul>',nl
∇
∇ R←ActiveIf nam
⎕←z←∨/(⎕← #.Strings.uc nam) ⍷ ⎕← #.Strings.uc #.HTMLUtils.enlist ⍕ #.Pages.⎕INSTANCES #.Pages.Klassenweb
R←z/' class="active"'
R,←'><a href="/',nam,'.dyalog">'
∇
The function ActiveIf should return the string class="active if the name of the linked class matches the name of the "currently active child-class" and then append the opening a-tag. The idea of checking ⎕INSTANCES only works as long as the other pages haven't been active, so I need another way to find the current instance of a class that called a fn in the base class it inherited from. Surely there must be an elegant way to do this, but I'm afraid I missed that bit... :((
-
MBaas - Posts: 156
- Joined: Thu Oct 16, 2008 1:17 am
- Location: Gründau / Germany
Re: A bit of OO for a nice menu...
Hi Michael,
I am not sure I understand what you are trying to do.
You seem to activate menu items according to the presence of instances but isn't there another way you could determine that more realistically? There must be some internal conditions that rule that. You could set global variables in your instances for example.
BTW, in MS3 there are a couple of examples of menus using SyncFusion menus. It may not solve your problem here but it could save you time elsewhere. They're in MS3/Examples.
/Dan
I am not sure I understand what you are trying to do.
You seem to activate menu items according to the presence of instances but isn't there another way you could determine that more realistically? There must be some internal conditions that rule that. You could set global variables in your instances for example.
BTW, in MS3 there are a couple of examples of menus using SyncFusion menus. It may not solve your problem here but it could save you time elsewhere. They're in MS3/Examples.
/Dan
- DanB|Dyalog
Re: A bit of OO for a nice menu...
Hi Dan,
yes, you understood it correctly. I may have 3 .Dyalog-files (a.dyalog, b.dyalog and c.dyalog) and currently each of them is linked to an entry in the (non-hierarchical) menu.
So, when I render the a.dyalog, the corresponding menu-item for a should have a class 'active' as in this screenshot:
Since the menu is created in the base-class of all pages in that web, my main concern was how to find out which instance was "responsible" for the call of the menu-function. (Yes, I also thought about an additional field which would handle the menu-representation of a class within that web, but that would have meant too much data-maintenance at too many places - I like to "centralize" such things to one place...)
I finally ended up with this:
But it doesn't "feel right",because it relies on "APL-mechanics" instead of "OO-mechanics", as the fictional function ⎕CurrentInstance would do.
yes, you understood it correctly. I may have 3 .Dyalog-files (a.dyalog, b.dyalog and c.dyalog) and currently each of them is linked to an entry in the (non-hierarchical) menu.
So, when I render the a.dyalog, the corresponding menu-item for a should have a class 'active' as in this screenshot:
Since the menu is created in the base-class of all pages in that web, my main concern was how to find out which instance was "responsible" for the call of the menu-function. (Yes, I also thought about an additional field which would handle the menu-representation of a class within that web, but that would have meant too much data-maintenance at too many places - I like to "centralize" such things to one place...)
I finally ended up with this:
- Code: Select all
∇ R←IfInstance nam
R←∨/(#.Strings.uc '[',nam,']') ⍷ #.Strings.uc #.HTMLUtils.enlist ⍕ ⎕NSI
∇
But it doesn't "feel right",because it relies on "APL-mechanics" instead of "OO-mechanics", as the fictional function ⎕CurrentInstance would do.
-
MBaas - Posts: 156
- Joined: Thu Oct 16, 2008 1:17 am
- Location: Gründau / Germany
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group