I am lost at trying to achieve a menu like this in typoscript.These pages should not be in the menu : excludeUidList = 2,3,5,6,7,48,49,50,51,52
<ul>
<li>
<span>First page</span><i class="fa fa-plus"></i>
<ul class="submenu">
<li>
</i>
<ul class="submenu">
<li>sub sub page</li>
<li>sub sub page</li>
</ul>
</li>
<li>
<span>Title</span>
</li>
<li>
<a href="link to third sub-page" class="submenu-toggle" ><span>Title</span></a>
</li>
</ul>
</li>
<li>
</i>
<ul class="submenu">
<li>
</i>
</li>
<li>
</i>
</li>
</ul>
</li>
</ul>
Could anyone point me in the right direction?Help would be appreciated
ok just in case someone has the same problem here is what i did and it works fine for me
lib.theMenuMobile = HMENU
lib.theMenuMobile {
entryLevel = 0
excludeUidList = 2,3,5,6,7,48,49,53,54,55
1 = TMENU
1 {
wrap = <ul>|</ul>
expAll = 1
NO = 1
NO {
wrapItemAndSub = <li class="uppermobilelink">|</li>
stdWrap.htmlSpecialChars = 1
ATagTitle.field = title
ATagBeforeWrap = 1
ATagParams = href="#" class="submenu-toggle mldisabled"
linkWrap = |<i class="fa fa-plus"></i>
}
}
2 < .1
2.wrap = <ul class="submenu">|</ul>
2.NO {
ATagTitle.field = subtitle
ATagParams = href="#" class="submenu-toggle"
linkWrap = |<i class="fa fa-plus"></i>
wrapItemAndSub = <li>|</li>
}
3 < .2
}
Related
I have several pages with subpages in my pagetree as shown below.
My pagetree with subpages
However, the links to the subpages do not seem to be clickable.
I have implemented my navigation in Fluid, as per the code below (which is in the default.html file in the Layouts folder):
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="{rl}">Company Name</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<f:for each="{mainnavigation}" as="mainnavigationItem">
<f:if condition="{mainnavigationItem.children}">
<f:then>
<li class="nav-item {f:if(condition: mainnavigationItem.active, then:'active')} dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{mainnavigationItem.title}
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<f:for each="{mainnavigationItem.children}" as="child">
<a class="dropdown-item" href="{child.link}" target="{child.target}" title="{child.title}">{child.title}</a>
</f:for>
</div>
</li>
</f:then>
<f:else>
<li class="nav-item {f:if(condition: mainnavigationItem.active, then:'active')}">
<a class="nav-link" href="{mainnavigationItem.link}" target="{mainnavigationItem.target}" title="{mainnavigationItem.title}">{mainnavigationItem.title} <span class="sr-only">(current)</span></a>
</li>
</f:else>
</f:if>
</f:for>
</ul>
</div>
</nav>
And the mainnavigation variable is defined in the configuration of my extension in setup.typoscript as shown below. Note that levels is set to 2, in order to render the subpages.
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = media
}
20 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
20 {
levels = 2
includeSpacer = 1
as = mainnavigation
}
}
As you can see in the picture below, an arrow is added for the subpages. When I click this arrow or the page title, nothing happens however.
The menu with dropdowns
Additionally I am getting this error in the webconsole:
Uncaught TypeError: Cannot read property 'fn' of undefined
at util.js:55
at bootstrap.min.js:6
at bootstrap.min.js:6
Which refers to:
$.fn.emulateTransitionEnd = transitionEndEmulator
You should have a look at your Setup – there you are able to define the navigation, see also here
You have a syntax error in your html code.
Your code:
<a class="dropdown-item" href="{child.link}" target="{child.target}" title="{child.title}>{child.title}</a>
Should be:
<a class="dropdown-item" href="{child.link}" target="{child.target}" title="{child.title}">{child.title}</a>
Missing " after {child.title}, so the is not closed correctly.
Turns out I was not importing JQuery correctly in setup.typoscript. Once I added the following code to page, the subpages popped up correctly:
includeJSFooter {
jquery = https://code.jquery.com/jquery-3.3.1.slim.min.js
jquery.external = 1
popper = https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js
popper.external = 1
bootstrap = https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js
bootstrap.external = 1
}
I'm trying to get the navigation bar of my first website to work but I can't find my mistake.. I'm working with Typo3, Fluid and Bootstrap. When I create a navigation bar manually in my template file it works perfectly fine but whatever I try in this typoscript file, the navigation bar items are only normal links instead of nav-items.
lib.navbar = HMENU
lib.navbar {
entryLevel = 1
1 = TMENU
1 {
wrap = <ul class="navbar-nav">|</ul>
NO = 1
NO {
wrapItemAndSub = <li class="nav-item">|</li>
stdWrap.htmlSpecialChars = 1
ATagTitle.field = title
}
ACT <.NO
ACT {
wrapItemAndSub = <li class="nav-item active">|</li>
}
}
}
I call the file in my template like this
<f:cObject typoscriptObjectPath="lib.navbar" />
This simple copy pasta in my template works
<nav class="navbar navbar-toggleable-md navbar-light bg-faded">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">Navbar</a>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
</div>
</nav>
It seems like the
wrap = <ul class="navbar-nav">|</ul>
gets ignored but when I try
wrap = <h1><ul class="navbar-nav">|</ul></h1>
the h1 works.
Edit: Fixed it with this line:
ATagParams = class="nav-link"
You can try below menu typoscript.
lib.navbar = HMENU
lib.navbar{
1 = TMENU
1{
expAll = 1
wrap = <ul class="navbar-nav mr-auto">|</ul>
NO {
allWrap = <li class="nav-item"> | </li>
ATagParams = class="nav-link"
}
ACT = 1
ACT {
wrapItemAndSub = <li class="nav-item active"> | <span class="sr-only">(current)</span></li>
ATagParams = class="nav-link"
}
}
}
Thanks, but it has the same problem. I found the reason though. The pages names are still inside an
<a href="index.php?id=1">
When I manually change it to
<a class="nav-link" href="index.php?id=1">
it works. But I don't know where this comes from in my code or how I can change it.
I have the following structure HTML code
<ul id="list_abcxyz">
<li class="label even-row">
<a class="label-link lia-link-navigation" rel="tag" id="link_c19bf51ba9103c" href="test.html">Label One<wbr></a>
<span class="label-count">(1)</span>
</li>
<li class="label odd-row">
<a class="label-link lia-link-navigation" rel="tag" id="link_c19bf51ba9103c_0" href="test2.html">Label Two<wbr></a>
<span class="label-count">(1)</span>
</li>
<li class="label even-row">
<a class="label-link lia-link-navigation" rel="tag" id="link_c19bf51ba9103c_1" href="test3.html">Label Three<wbr></a>
<span class="label-count">(1)</span>
</li>
How to convert it to a select drop down? I have tried following the guides in community. But those didn't work. I guess because of extra span tag. But I need that span tag as well.
How can we convert it to select option drop down using JS ?
Thank you.
Something like this should get you started. If you were running into trouble with the <span> then you can use the textContent property to get all text without the html tags included, then remove all multiple spaces with a replace() and trim().
var myform = document.getElementById('myform'),
items = document.getElementById('list_abcxyz').getElementsByTagName('li'),
select = document.createElement('select'),
len = items.length,
option;
for(var i = 0; i < len; i++) {
option = document.createElement('option');
var label = items[i].textContent.replace(/\s\s+/g," ").trim(),
link = items[i].getElementsByTagName('a')[0].href;
option.textContent = label;
option.value = link;
select.appendChild(option);
}
myform.appendChild(select);
select.addEventListener('change',function(evt){
var selectedLink = this.options[this.selectedIndex].value;
console.log(selectedLink);
location.href = selectedLink;
});
<ul id="list_abcxyz">
<li class="label even-row">
<a class="label-link lia-link-navigation" rel="tag" id="link_c19bf51ba9103c" href="test.html">Label One<wbr></a>
<span class="label-count">(1)</span>
</li>
<li class="label odd-row">
<a class="label-link lia-link-navigation" rel="tag" id="link_c19bf51ba9103c_0" href="test2.html">Label Two<wbr></a>
<span class="label-count">(1)</span>
</li>
<li class="label even-row">
<a class="label-link lia-link-navigation" rel="tag" id="link_c19bf51ba9103c_1" href="test3.html">Label Three<wbr></a>
<span class="label-count">(1)</span>
</li>
</ul>
<form id="myform">
</form>
We are migrating an asp.net intranet to SharePoint and automating the conversion via PowerShell.
We only want to scrap links from within the DIV tag with a classname 'topnav'. Not all the links on the page
$url = "http://intranet.company.com"
$page = Invoke-WebRequest -Uri $url
$div_topnav = $page.ParsedHtml.getElementsByTagName('div') | ? {$_.className -match 'topnav'}
This gets us the HTML of the topnav, but how best to extract just the application links from the Applications nodes? We do not want HOME or Documents nodes?
<div class="topnav" >
<ul class="lev1 clearfix" >
<li class="lev1 pos1 first lev1_first">
Home
</li>
<li class="lev1 pos2 haschildren lev1_haschildren">
Applications
<ul>
<li class="lev2 pos1 first lev2_first">
App 1
</li>
<li class="lev2 pos2 haschildren lev2_haschildren">
Training
<ul class="lev3">
<li class="lev3 pos1 lev3_pos1 first lev3_first">
App 3
</li>
<li class="lev3 pos2 lev3_pos2 last lev3_last">
App 4
</li>
</ul>
</li>
</ul>
<li class="lev1 pos3 haschildren lev1_haschildren">
Documents
<ul>
<li class="lev2 pos1 first lev2_first">
Doc 1
</li>
<li class="lev2 pos2 haschildren lev2_haschildren">
Training
<ul class="lev3">
<li class="lev3 pos1 lev3_pos1 first lev3_first">
Doc 3
</li>
<li class="lev3 pos2 lev3_pos2 last lev3_last">
Doc 4
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
I think that is what you want:
[xml]$div_topnav=
#"<div class="topnav" >
<ul class="lev1 clearfix" >
<li class="lev1 pos1 first lev1_first">
Home
</li>
<li class="lev1 pos2 haschildren lev1_haschildren">
Applications
<ul>
<li class="lev2 pos1 first lev2_first">
App 1
</li>
<li class="lev2 pos2 haschildren lev2_haschildren">
Training
<ul class="lev3">
<li class="lev3 pos1 lev3_pos1 first lev3_first">
App 3
</li>
<li class="lev3 pos2 lev3_pos2 last lev3_last">
App 4
</li>
</ul>
</li>
</ul>
</li>
<li class="lev1 pos3 haschildren lev1_haschildren">
Documents
<ul>
<li class="lev2 pos1 first lev2_first">
Doc 1
</li>
<li class="lev2 pos2 haschildren lev2_haschildren">
Training
<ul class="lev3">
<li class="lev3 pos1 lev3_pos1 first lev3_first">
Doc 3
</li>
<li class="lev3 pos2 lev3_pos2 last lev3_last">
Doc 4
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
"#
($div_topnav.GetElementsByTagName("a") | ? "#Text" -Like "App *").href
The output will be your links of all of your apps.
PowerShell couldn't parse your posted $div_topnav Content, because there is a closing li-tag missing for your li-tag in line 6 (I fixed that in my Code snippet).
I am trying jsTree for the first time, and have the problem that after calling jstree(), the text in my <li> elements vanishes. After the call, my tree looks like this:
<div id="assessment-treeview" class="jstree jstree-0 jstree-focused jstree-classic">
<ul>
<li class="jstree-last jstree-open"><ins class="jstree-icon"> </ins>
<ul style="">
<li class="jstree-last jstree-open"><ins class="jstree-icon"> </ins>
<ul style="">
<li class="jstree-last jstree-leaf"><ins class="jstree-icon"> </ins></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
Before the call it looks like this:
<div id="assessment-treeview">
<ul>
<li>Specific Outcomes
<ul>
<li>[section: name not available for import]
<ul>
<li>[outcome: name not available for import] </li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
The jstree call looks like this:
$("#assessment-treeview").jstree({ "themes": { "theme": "classic" } });
What could be causing this?
jsTree doesn't like pure text nodes inside the 'li' tag. When I put the item text into a tag like 'span', everything worked fine again.
From the question code above:
<li><span>Specific Outcomes</span>
<ul>
.
.
</ul>
</li>