TYPO3 - TypoScript TMENU ACT-object before NO-object - twitter-bootstrap-3

I'm trying to find out how to put a TMENU: .ACT-object before a TMENU: .NO-object, since I'm trying to achieve a Bootstrap 3.3.7 dropdown menu structure with the active item as leading <li>-element.
Currently I'm stuck on this part and I hope anyone can get me started to finish this structure. The structure I'm trying to achieve is the following:
<ul class="nav navbar-nav navbar-right pull-right" role="menu">
<li class="dropdown language-menu lang eng">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
<span>English</span>
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li class="lang fr"><span>Français</span></li>
<li class="lang de><a><span>Deutsch</span></a></li>
<li class="lang es><a><span>Español</span></a></li>
<li class="lang pt><a><span>Portugues</span></a></li>
<li class="lang nl><a><span>Nederlands</span></a></li>
</ul>
</li>
</ul>
The only thing that goes wrong at the moment, is that the TMENU .ACT-object is appending the TMENU: .NO-object. It is being put insite the <ul class="dropdown-menu">-element.
The TypoScript I am using:
20 = HMENU
20 {
special = language
special.value = 0,1,2,3,4,5
current = 1
wrap = <ul class="nav navbar-nav navbar-right pull-right" role="menu">|</ul>
1 = TMENU
1 {
wrap = <ul class="dropdown-menu">|</ul>
NO = 1
NO {
allWrap = <li class="lang eng">|</li> || <li class="lang nl">|</li> || <li class="lang fr">|</li> || <li class="lang de">|</li> || <li class="lang es">|</li> || <li class="lang pt">|</li>
ATagParams =
ATagBeforeWrap = 1
linkWrap = <span>|</span>
}
#ACT < .NO
ACT = 1
ACT {
allWrap = <li class="dropdown language-menu lang eng">|</li>
}
}
}
I have tried a lot the last two days and I'm hoping anyone can help me out, or at least get me started so I know where my mistakes are.
Thanks a lot!

in general ACT is put inline amongst the NO menu items. to split it up so you have the ACT separated in front of the other NO items you need to render the menu two times: first only the ACT item(s) followed by the NO items.
as you want to have one UL-tag around it I would try a COA with that UL-wrap and then two menus where the first one only renders ACT with their LI-wrap and the second only the NO with their LI-wrap.
20 = COA
20 {
wrap = class="nav navbar-nav navbar-right pull-right" role="menu">|</ul>
10 = HMENU
10 {
special = language
special.value = 0,1,2,3,4,5
current = 1
1 = TMENU
1 {
ACT = 1
ACT.allWrap (
<li class="dropdown language-menu lang eng">|</li> ||
<li class="dropdown language-menu lang nl">|</li> ||
<li class="dropdown language-menu lang fr">|</li> ||
<li class="dropdown language-menu lang de">|</li> ||
<li class="dropdown language-menu lang es">|</li> ||
<li class="dropdown language-menu lang pt">|</li>
)
NO.doNotShowLink = 1
}
}
20 < .10
20 {
ACT.doNotShowLink = 1
NO >
NO = 1
NO {
allWrap (
<li class="lang eng">|</li> ||
<li class="lang nl">|</li> ||
<li class="lang fr">|</li> ||
<li class="lang de">|</li> ||
<li class="lang es">|</li> ||
<li class="lang pt">|</li>
)
ATagParams =
ATagBeforeWrap = 1
linkWrap = <span>|</span>
}
}

Based on Bernd Wilke's answer this is what finally worked for me:
lib.menuLanguage = COA
lib.menuLanguage {
10 = HMENU
10 {
special = language
special.value = 0,1
1 = TMENU
1 {
ACT = 1
ACT {
linkWrap = <li class="extra">| <b class="caret"></b><ul class="dropdown-menu">
doNotLinkIt = 1
stdWrap {
override = EN || DE
}
}
NO = 1
NO.doNotShowLink = 1
}
}
20 < .10
20.1 {
ACT >
NO >
NO = 1
NO {
doNotLinkIt = 1
linkWrap = <li>|</li>
stdWrap {
override = EN || DE
typolink {
parameter.data = page:uid
additionalParams = &L=0 || &L=1
ATagParams = hreflang="en-GB" || hreflang="de-DE"
addQueryString = 1
addQueryString.exclude = L,id,no_cache
addQueryString.method = GET
no_cache = 0
}
}
}
}
wrap = |</ul></li>
}
with this template:
<ul class="nav navbar-nav navbar-right">
<f:cObject typoscriptObjectPath='lib.menuLanguage' />
</ul>

Related

iterating number type in express-edge?

isn't it possible to itereate through a number type variable in express-edge? On their official docs they mentioned iteration of objects and arrays and when I tried to iterate a number type variable it didn't worked (i mean like a simple loop, will run for n times)
so basically i'm trying to impelment a pagination, my controller for this look something like this:
// get total documents in the Posts collection
const count = await Posts.countDocuments();
const tpgs = Math.ceil(count / limit);
// return response with posts, total pages, and current page
res.render("index",{
psts: posts,
totalPages: tpgs,
currentPage: page
});
and the html (with express-edge) looks something like this:
#if(totalPages > 0)
<nav aria-label="Page navigation example">
<ul class="pagination">
#each(p in totalPages)
#if(p == 1)
<li class="page-item disabled">
<a class="page-link" href="#" tabindex="-1" aria-disabled="true">Previous</a>
</li>
#else
<li class="page-item"><a class="page-link" href="posts/{{ p - 1}}">Previous</a></li>
#endif
#if(p == currentPage)
<li class="page-item active" aria-current="page">
<a class="page-link" href="{{ p }}">{{ p }}</a>
</li>
#else
<li class="page-item"><a class="page-link" href="posts/{{ p }}">{{ p }}</a></li>
#endif
#if(p == totalPages)
<li class="page-item disabled">
<a class="page-link" href="posts/{{ p + 1}}">Next</a>
</li>
#else
<li class="page-item">
<a class="page-link" href="posts/{{ p + 1}}">Next</a>
</li>
#endif
#endeach
</ul>
</nav>
#endif

How to change `ReflectionIT.Mvc.Paging` package style in asp.net core

I am working on a Asp.net core 2.2 project and use ReflectionIT.Mvc.Paging package for paging.
Every thing is ok but i want to change paging style in my view.
Here is code to use Pager view component
<nav>
#await this.Component.InvokeAsync("Pager", new { PagingList = this.Model })
</nav>
And here is paging pic :
I want to write First And Last instead of 1 And 15 in above pic and want to change some css styles.
You can also create your own Pager view if you want to. You store it in the folder Views\Shared\Components\Pager :
You can for instance call the AddPaging method which you can use to set the PagingOptions. This allows you to specify which View is used for the Pager ViewComponent , in ConfigureServicesfunction :
// Register ViewComponent using an EmbeddedFileProvider & setting some options
services.AddPaging(options => {
options.ViewName = "Bootstrap5";
options.HtmlIndicatorDown = " <span>↓</span>";
options.HtmlIndicatorUp = " <span>↑</span>";
});
Modify the Bootstrap5.cshtml to fit your requirement :
#model ReflectionIT.Mvc.Paging.IPagingList
#* Fake Boostrap 5 based pager *#
#{
var start = this.Model.StartPageIndex;
var stop = this.Model.StopPageIndex;
}
#if (this.Model.PageCount > 1) {
<ul class="pagination pagination-sm justify-content-end">
#if (start > 1) {
<li class="page-item">
<a href="#Url.Action(Model.Action, Model.GetRouteValueForPage(1))" aria-label="First" class="page-link">
<span aria-hidden="true">First</span>
</a>
</li>
}
#if (this.Model.PageIndex > 1) {
<li class="page-item">
<a href="#Url.Action(Model.Action, Model.GetRouteValueForPage(this.Model.PageIndex - 1))" aria-label="Previous" class="page-link">
<span aria-hidden="true">«</span>
</a>
</li>
}
#for (int i = start; i <= stop; i++) {
<li class="page-item #((Model.PageIndex == i) ? "active" : null)">
#if (i == 1)
{
#Html.ActionLink("First", Model.Action, Model.GetRouteValueForPage(i), new { #class = "page-link" })
}
else{
#Html.ActionLink(i.ToString(), Model.Action, Model.GetRouteValueForPage(i), new { #class = "page-link" })
}
</li>
}
#if (this.Model.PageIndex < this.Model.PageCount) {
<li class="page-item">
<a href="#Url.Action(Model.Action, Model.GetRouteValueForPage(this.Model.PageIndex + 1))" aria-label="Next" class="page-link">
<span aria-hidden="true">»</span>
</a>
</li>
}
#if (stop < this.Model.PageCount) {
<li class="page-item">
<a href="#Url.Action(Model.Action, Model.GetRouteValueForPage(this.Model.PageCount))" aria-label="Last" class="page-link">
<span aria-hidden="true">Last</span>
</a>
</li>
}
</ul>
}
Output :
Try this one
services.AddPaging(options => {
options.ViewName = "Bootstrap4";
options.HtmlIndicatorDown = " <span>↓</span>";
options.HtmlIndicatorUp = " <span>↑</span>";
});

Getting nested <li> tags also.....just need the direct <li> item

I have a page structure where it includes hyperlinks with different levels of nested list items. I am writing the xpath for just the second nested list items(level 2) but it is also giving me all the list items below level 2(level 3 or below), which i don't need. It's getting really frustrating now because I have tried different xpaths and cssSelectors, everytime it is taking the level 3 list items along with level 2.
The page structure is exactly like following:
<div>
<ul class="menuBar_menu_lvl_0">
<li class="item_lvl_1">
<li class="item_lvl_1">
<ul class="menu_lvl_1">
<li class="item_lvl_2"></li>
<li class="item_lvl_2"></li>
<li class="item_lvl_2">
<ul class="menu_lvl_2">
<li class="item_lvl_3"></li>
<li class="item_lvl_3"></li>
<li class="item_lvl_3"></li>
</ul>
</li>
</ul>
<li class="item_lvl_1">
<li class="item_lvl_1">
xpath = //ul[#class="menuBar_menu_lvl_0"]//li[#class="item_lvl_1"]//ul[#class="menu_lvl_1"]//li[#class="item_lvl_2"]
This is also giving me item number 3 elements along with item level 2. I want to get each level item correctly and separately. Anybody's help would be highly appreciated
Welcome to SO.
Here is the sample that used.
<html>
<body>
<div>
<ul class="menuBar_menu_lvl_0">
<li class="item_lvl_1">
<li class="item_lvl_1">
<ul class="menu_lvl_1">
<li class="item_lvl_2">Level1-li1</li>
<li class="item_lvl_2">Level1-li2</li>
<li class="item_lvl_2">
<ul class="menu_lvl_2">
<li class="item_lvl_3">Level2-li1</li>
<li class="item_lvl_3">Level2-li2</li>
<li class="item_lvl_3">Level2-li1</li>
</ul>
Level1-li3
</li>
</ul>
<li class="item_lvl_1">
<li class="item_lvl_1">
</ul>
</div>
</body>
</html>
And below is the xpath
//ul[#class='menu_lvl_1']//li[not(parent::ul[#class='menu_lvl_2'])]
Here is the output:
Here is the method to get the text from parent element only.
def get_text_exclude_children(element):
return driver.execute_script(
"""
var parent = arguments[0];
var child = parent.firstChild;
var textValue = "";
while(child) {
if (child.nodeType === Node.TEXT_NODE)
textValue += child.textContent;
child = child.nextSibling;
}
return textValue;""",
element).strip()

Click on an Element in list Selenium Java

How can I click on the the element "one" in the following code:
<div class="navbar navbar-default">
<ul class="nav navbar-nav">
<li><a class="dropdown-toggle" data-toggle="dropdown" href="javascript:void(0);" id="Tiles">cat1 <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a id="Wid" href="javascript:void(0);">one</a></li>
<li><a id="Sett" href="javascript:void(0);">two</a></li>
<li><a id="Th" href="javascript:void(0);">three</a></li></ul></li>
<li><a class="dropdown-toggle" data-toggle="dropdown" href="javascript:void(0);" id="Groups">Cat2 <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a id="Events" href="javascript:void(0);">four</a></li>
<li><a id="Folder" href="javascript:void(0);">five</a></li>
<li><a id="Cat" href="javascript:void(0);">six</a></li>
<li class="disabled"><a id="Procedure" href="javascript:void(0);">Procedure</a></li></ul></li></div>
Thanks:)
"one" is not an element, so you can only locate its parent <a> element:
By.Id("Widgets")
From what I understand, "one" is one value from a dropdown list, correct? If so, you can use one of the following methods to find the dropdown list and the particular value, after you name them in a class:
public void selectFromDropDownListFoundById(String detailIDIdentifier, String text, String value) {
Select droplist = new Select(driver.findElement(By.id(detailIDIdentifier)));
// Choose to Select by Text or by Value of the drop-down list
if (text == null && value != null) {
droplist.selectByValue(value);
} else if (text != null && value == null) {
droplist.selectByVisibleText(text);
} else {
throw new AssertionError("Cannot be both parameters null. Give text or value");
}
}
public void selectFromDropDownListFoundByName(String detailIdIdentifier, String text, String value) {
Select droplist = new Select(driver.findElement(By.name(detailIdIdentifier)));
// Choose to Select by Text or by Value of the drop-down list
if (text == null && value != null) {
droplist.selectByValue(value);
} else if (text != null && value == null) {
droplist.selectByVisibleText(text);
} else {
throw new AssertionError("Cannot be both parameters null. Give text or value");
}
}

index of matching items in parent element even if they're in other child containers

I need to get the index of the li.play relevant to the ul.showreel_thumbnails. Is this even possible? All i seem to get is the li index inside ul.row
<ul class="showreel_thumbnails">
<li>
<ul class="row">
<li class="play_video">item</li>
<li class="play_video">item</li>
<li class="play_video">item</li>
</ul>
</li>
<li>
<ul class="row">
<li class="play_video">item 4</li>
<li class="play_video">item</li>
</ul>
</li>
</ul>
so if item 4 is clicked it should give me the index of 4 etc...
best, Dan.
It may not be valid HTML but here's how it would work (with JQuery):
function FindMyCount()
{
var item_count = 0;
$("#showreel_thumbnails li").each(function() {
++item_count;
if($(this).hasClass("igotclicked"))
return false;
});
return item_count;
}
$("#showreel_thumbnails li").click(function() {
$(this).addClass("igotclicked");
var myCount = FindMyCount(); // 1 - the # of li's under the showreel piece
$(this).removeClass("igotclicked");
// Do what you want here.
});