Creating Lift nested Submenus in different div - scala

I'm trying to build a nested menu structure, but the submenus should appear in a different element on the page.
Grouping and hiding the submenus will make them appear always, not just after activating the parent menu.
Menu.i("Startseite") / "index" >> Hidden >> LocGroup("servicenav"),
Menu.i("Impressum") / "about"/"index" >> Hidden >> LocGroup("servicenav"),
Menu.i("menu_1") / "100_menu1" submenus(
Menu.i("menu_1a") / "100_menu1a" >> Hidden >> LocGroup("sidenavbar"),
Menu.i("menu_1b") / "200_menu1b" >> Hidden >> LocGroup("sidenavbar"),
Menu.i("menu_1c") / "300_menu1c" >> Hidden >> LocGroup("sidenavbar")
),
Menu.i("menu_2") / "400_menu2" submenus(
Menu.i("menu_2a") / "400_menu2a" >> Hidden >> LocGroup("sidenavbar"),
Menu.i("menu_2b") / "500_menu2b" >> Hidden >> LocGroup("sidenavbar")
)
)
And the html part:
<ul id="mainnav">
<lift:Menu.builder li_item:class="open" li_path:class="open">
Upper Navigation Panel for primary Menu
</lift:Menu.builder>
</ul>
<ul id="nav">
<lift:Menu.group group="sidenavbar" a:class="firstChild">
Side-Navigation panel for submenus
<li><menu:bind /></li>
</lift:Menu.group>
</ul>
Has anyone a good idea?
Thanks in advance

You didn't specify the "group" in the first part of the HTML. Maybe this would help ?

I understood you incorrectly the first time.
Would level solve your problem?
level: What level of the entire selected menu tree to show. Counting begins at zero, for the top level. Consider a top level menu with ‘item1’, ‘item2’, and ‘item3’ and supposed ‘item1’ has a submenu with items ‘item1a’ and ‘item1b’. Level 0 will show the top level plus the submenus (see next option). If item2 or item3 is selected level 1 will show nothing, while if one of the item1 variants is selected the item1a and item1b entries will be displayed.
https://www.assembla.com/wiki/show/liftweb/SiteMap#using_sitemap_in_templates

Ok, I created a workaround by grouping the top-menu level and let the submenu appear in the main-sitemap. With this, the level-parameter can be applied and therefore only the active submenus appear in the div.
Menu.i("Startseite") / "index" >> Hidden >> LocGroup("servicenav"),
Menu.i("Impressum") / "about"/"index" >> Hidden >> LocGroup("servicenav"),
Menu.i("menu_1") / "100_menu1" >> LocGroup("mainnavbar") submenus(
Menu.i("menu_1a") / "100_menu1a",
Menu.i("menu_1b") / "200_menu1b",
Menu.i("menu_1c") / "300_menu1c"
),
Menu.i("menu_2") / "400_menu2" >> LocGroup("mainnavbar") submenus(
Menu.i("menu_2a") / "400_menu2a",
Menu.i("menu_2b") / "500_menu2b"
)
And the HTML:
<ul id="mainnav">
<lift:Menu.group group="mainnavbar" level="1">
<li><menu:bind />
</li>
</lift:Menu.group>
</ul>
<div id="navblock">
<ul id="nav">
<lift:Menu.builder level="1" li_item:class="opfirstChildOpenen" li_path:class="firstChildOpen">
Side-Navigation panel for submenus
</lift:Menu.builder>
</ul>
</div>

So, finally got a solution.
I simlpy added two Sitemaps. The first with with level="0" and expand="false", the second with level="1". However if you click in the second menu, the first will expand regardless of the expand parameter. So I set the in the stylesheet the width and heigth for the following in the first menu to 0.
Not clean, but it works...
<ul id="mainnav">
<lift:Menu.builder li_path:class="open" level="0" expand="false">
Top Menu
</lift:Menu.builder>
</ul>
<ul id="nav">
<lift:Menu.builder level="1" li_item:class="current" li_path:class="open">
Side-menu
</lift:Menu.builder>
</ul>
ul#mainnav li ul li{
height: 0;
width: 0;
}

Related

Adjusting CFWindow position on the screen, is it possible?

I try to use cfwindow to deliver an error/warning message to my users. It works but the only problem is the pop up window is off the screen all the way to the bottom sinking to the task bar.
I thought I can use the x and y attributes but I tried them and they did not work.
Is it possible to adjust the positioning of cfwindow at all so when it shows up it will be in the middle of the screen or at least in the middle up instead of sinking down below?
<CFTRY>
<cffile action="upload" filefield="uploadfile" destination="#TempDestination#" nameConflict="overwrite" result="myupload">
<cfdump var="#myupload#">
<CFCATCH type="Any">
<cfwindow initShow="true" title="Minute Upload Problem" center="true" height="200" width="400"
x="880" y="850"
bodyStyle="font-family: verdana; color: ##000000; font-size: 13;"
headerStyle="font-family: verdana; background-color: ##ff0000; color: ##ffffff"
resizable="False" name="NoPermission">
<!--- message --->
<div align="center">
Destination Folder may not be set to accept your file<br>
Please contact the webmaster.
</div>
</cfwindow>
</CFCATCH>
</CFTRY>
To fit the window as per x & y coordinates, you will have to set
center="false"
If center is set to true, then it will take precedence over the x & y coordinates. I have set center="false". Now, the position of the new popup windows changes, as I change the x & y coordinates.

Selecting sibling nodes using position()

I've got a trouble selecting divs following specific title in code:
<div>
<h2>Section 1</h2>
<div>Item 1</div>
<div>Item 2</div>
<h2>Section 2</h2>
<div>Item 3</div>
<div>Item 4</div>
<div>Item 5</div>
</div>
I was trying to get the nodes using preceding-sibling somehow like this:
//div/div[preceding-sibling::h2[1][position()=1]]
I need all divs which have the NEAREST preceding h2 sibling on position 1, but I'm still getting all 5 items.
Can you tell me what am I doing wrong?
Example output with position 1 (section 1):
<div>Item 1</div>
<div>Item 2</div>
Example output with position 2 (section 2):
<div>Item 3</div>
<div>Item 4</div>
<div>Item 5</div>
This can be a tricky thing to do, but one approach you can use is count():
//div/div[count(preceding-sibling::h2) = 1]
The reason your attempt with position() didn't work is that position() is evaluated relative to the current selection. With preceding-sibling::h2[1][position()=1], you are selecting the nearest h2 and then selecting the first node in that set.

Simple HTML DOM find multiple tags simultaneously

I have a string:
<h2>header 1</h2>
<p>paragraph 1</p>
<h2>header 2</h2>
<h3>siausjfks</h3>
....(anything not containing h2 and p tags)
<div><h2>header 3</h2> jasgfks</div>
.... (anything not containing h2 and p tags)
<p>paragraph 2</p>
Now i want to have array
element 1 = header 1
element 2 = paragraph 1
element 3 = header 2
element 4 = header 3
element 5 = paragraph 2
Is there a way to accomplish this using simple HTML DOM?
Thanks :)
UPDATE: This is actually to find 2 tags simultaneously, how about finding 3, 4 and more tags?

Typoscript Breadcrumb - special.range parameter

I'm struggling with a simple Breadcrumb Navigation in Typoscript. I just want a simple link to the higher-level page. So if you're on page-3 there should be a link to page-2, if on page-4 there should be a link to page-4 and so on.
I've already been testing different special.range parameters. None of them worked for me.
From docs:
If the value is < 0, entryLevel is chosen from "behind" in the rootLine. Thus "-1" is a menu with items from the outermost level, "-2" is the level before the outermost...
In rootline menu that means the -1 level is current page, -2 one level above current, etc. so linking only parent level is as simple as:
lib.linkOneLevelAbove = HMENU
lib.linkOneLevelAbove {
special = rootline
special.range = -2|-2
1 = TMENU
1.NO = 1
}
page.1 < lib.linkOneLevelAbove

Opacity toggle three (or more) DIV

<div id="rotator">
<p id="1">Some Text 1</p>
<p id="1">Some Text 2</p>
<p id="1">Some Text 3</p>
</div>
They are presented in a row. All I want is automatically cycle the three text by toggling opacity, ie. at first text 1 is opacity 1, and test 2 and 3 are opacity .5. Then after 5 seconds or so, text 2 is opacity 1, and text 1 and three are opacity .5... so on in a cycle.
Can someone give me a hint/direction on how to do this in jquery please. Thank you in advance.