Typo3 BootStrap 3 navbar (typoscript) - twitter-bootstrap-3

Hi I am new to typoscript and I need help in getting the menu working. The following typoscript will render the Bootstrap navbar, yet the menu is thrown out of the navbar completely without css styles.
topnavigation = HMENU
topnavigation.wrap (
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
<a class="navbar-brand" href="http://www.example.com">Brand</a></div>
<div class="collapse navbar-collapse" id="navbar-collapse">
<ul class="nav navbar-nav">
</ul>
</div>
</div>
</nav>
)
topnavigation.entryLevel = 0
topnavigation {
1= TMENU
1 {
expAll = 1
maxItems = 4
NO.wrapItemAndSub = <li>|</li>
ACT = 1
ACT.wrapItemAndSub = <li class="active">|</li>
IFSUB = 1
IFSUB.wrapItemAndSub = <li class="dropdown">|</li>
ACTIFSUB = 1
ACTIFSUB.wrapItemAndSub= <li class="active dropdown">|</li>
}
2= TMENU
2 {
wrap = <ul class="dropdown-menu">|</ul>
NO.wrapItemAndSub = <li>|</li>
ACT = 1
ACT.wrapItemAndSub = <li class="active">|</li>
}
}
Please help

You haven't pipe symbol in your topnavigation.wrap anywhere...
Each wrap should use pipe symbol | in the place where the wrapped content should be placed, as i.e. in your TMENU:
NO.wrapItemAndSub = <li>|</li>
Anyway your general wrap with this whole Bootstrap markup doesn't have it, most probably that's the reason of wrong rendering...
Most probably it should be somewhere there:
...
<ul class="nav navbar-nav">|</ul>
...
BTW, use browser's inspector tools to check what's missing, we can only guess.

Biesior, thanks for pipe suggestions, it did set me in the right direction. After a load of research and hacking (not being a coder and alien to typoscript), I managed to get the bootstrap 3 inverse navbar working correctly with in typo3.
The following code works out of the box.
topnavigation = HMENU
topnavigation.wrap (
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="http://www.example.com">Your Company Name or Logo</a>
</div>
<div class="collapse navbar-collapse" id="navbar-collapse">
<ul class="nav navbar-nav">|</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container -->
</nav>
)
topnavigation.entryLevel = 0
topnavigation {
1 = TMENU
1 {
expAll = 1
NO.allWrap = <li>|</li>
NO.ATagTitle.field = abstract // description // title
ACT = 1
ACT.wrapItemAndSub = <li class="active">|</li>
ACT.ATagTitle.field = abstract // description // title
IFSUB = 1
IFSUB.before = <a href="#" class="dropdown-toggle" data-toggle="dropdown">
IFSUB.after = <b class="caret"></b></a>
IFSUB.doNotLinkIt = 1
IFSUB.wrapItemAndSub = <li class="dropdown">|</li>
IFSUB.ATagTitle.field = abstract // description // title
ACTIFSUB = 1
ACTIFSUB.before = <a href="#" class="dropdown-toggle" data-toggle="dropdown">
ACTIFSUB.after = <b class="caret"></b></a>
ACTIFSUB.doNotLinkIt = 1
ACTIFSUB.wrapItemAndSub = <li class="dropdown active">|</li>
ACTIFSUB.ATagTitle.field = abstract // description // title
}
2 = TMENU
2 {
expAll = 1
ACT = 1
ACT.wrapItemAndSub = <li class="active">|</li>
ACT.ATagTitle.field = abstract // description // title
ACTIFSUB = 1
ACTIFSUB.wrapItemAndSub = |
ACTIFSUB.before = <li class="divider"></li><li class="nav-header">
ACTIFSUB.after = </li>
ACTIFSUB.doNotLinkIt = 1
ACTIFSUB.ATagTitle.field = abstract // description // title
NO.allWrap = <li>|</li>
NO.ATagTitle.field = abstract // description // title
IFSUB = 1
IFSUB.before = <li class="divider"></li><li class="nav-header">
IFSUB.after = </li>
IFSUB.doNotLinkIt = 1
IFSUB.ATagTitle.field = abstract // description // title
SPC = 1
SPC.allWrap = <li class="divider"></li><li class="nav-header">|</li>
wrap = <ul class="dropdown-menu">|</ul>
}
3 = TMENU
3 {
NO.allWrap = <li>|</li>
NO.ATagTitle.field = abstract // description // title
ACT = 1
ACT.wrapItemAndSub = <li class="active">|</li>
ACT.ATagTitle.field = abstract // description // title
}
}
Remember to refer to the extension in the main page (fileadmin/your_template/layouts/your_main_page.html)
<f:cObject typoscriptObjectPath="topnavigation" />

Related

Layout page in dot net core not showing changes on click from Index page

I have menus on Layout page and I need to make them enabled on click of button which is there on Index view
On Index button click I have called controller action which sets the flag using view bag and then I am enabling menu if the flag is set by checking condition on layout page, condition is checked correctly but still menu is not enabled, but if I am clicking any other button then menu is enabling
Layout.cshtml
#if (#ViewBag.Enable == "true" || Context.Session.GetString("CustomerCode") == null)
{
<a href="#OCLegacy" data-toggle="collapse" aria-expanded="false" style="color:gray" class="bg-dark list-group-item list-group-item-action flex-column align-items-start disabled">
<div class="d-flex w-100 justify-content-start align-items-center">
<span class="bi bi-diamond-fill fa-fw mr-3"></span>
<span class="menu-collapsed">OC-Legacy</span>
<span class="submenu-icon ml-auto"></span>
</div>
</a>
}
Index.cshtml
<a asp-action="Index" style="align-self:self-end" data-id="#customer.CustomerCode"
class="btn btn-primary ManageSelect">
calling index action from controller
Here is a demo with ViewBag.Enable. pass #customer.CustomerCode to action,if the it is not null,set ViewBag.Enable to true.Else,set ViewBag.Enable to false.If ViewBag.Enable is true,male the menu enable.
Layout:
#if (#ViewBag.Enable != "true")
{
<a href="#OCLegacy" data-toggle="collapse" aria-expanded="false" style="color:gray" class="bg-dark list-group-item list-group-item-action flex-column align-items-start disabled">
<div class="d-flex w-100 justify-content-start align-items-center">
<span class="bi bi-diamond-fill fa-fw mr-3"></span>
<span class="menu-collapsed">OC-Legacy</span>
<span class="submenu-icon ml-auto"></span>
</div>
</a>
}
else {
<a href="#OCLegacy" data-toggle="collapse" aria-expanded="false" style="color:gray" class="bg-dark list-group-item list-group-item-action flex-column align-items-start">
<div class="d-flex w-100 justify-content-start align-items-center">
<span class="bi bi-diamond-fill fa-fw mr-3"></span>
<span class="menu-collapsed">OC-Legacy</span>
<span class="submenu-icon ml-auto"></span>
</div>
</a>
}
Index(asp-route-id will pass #customer.CustomerCode as a parameter id to action):
<a asp-action="Index" style="align-self:self-end" asp-route-id="#customer.CustomerCode" data-id="#customer.CustomerCode"
class="btn btn-primary ManageSelect">
Action:
public IActionResult Index(string id)
{
if (id != null)
{
ViewBag.Enable = "true";
}
else
{
ViewBag.Enable = "false";
}
return View();
}
result:

Aurelia - Adding a list item username - to the navmenu creates an entry black on black and incorrectly positioned

I need to display the name of the user next to the logout option on my navbar. The way I did this was as follows:
<ul class="nav navbar-nav navbar-right">
<li>${userName}</li>
<li repeat.for="row of router.navigation" if.bind="row.settings.pos == 'right'" class="${ row.isActive ? 'link-active' : '' }">
<a href.bind="row.href" if.bind="!row.settings.nav">${ row.title }</a>
I thought that if I added another list item it in the nav navbar-nav it would display as all the other menu items do. Instead I got:
I have highlighted the name admin as, if I didnt it would be black on black. Its not receiving the correct styling as the other menu items have.
How do I render the admin list item so it displays like all the other list items?
EDIT
Looking at the question it was pointed out it was light on on background. It was late at night.
Yes I am using bootstrap version 3.
Here is the full html of the navbar view model:
<template>
<require from="./navmenu.css"></require>
<div class="main-nav">
<div class="navbar navbar-inverse">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#/home">Jobsledger</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-left">
<li repeat.for="row of routes" if.bind="row.settings.pos == 'left'" class="${ row.isActive ? 'link-active' : '' }">
<a href.bind="row.href" if.bind="!row.settings.nav">${ row.title }</a>
<a href.bind="row.href" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"
if.bind="row.settings.nav">
${row.title}
<span class="caret"></span>
</a>
<ul if.bind="row.settings.nav" class="dropdown-menu">
<li repeat.for="menu of row.settings.nav">
<a href.bind="menu.href">${menu.title}</a>
</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>${userName}</li> //HERE - THIS LINE DOESNT RENDER PROPERLY.
<li repeat.for="row of routes" if.bind="row.settings.pos == 'right'" class="${ row.isActive ? 'link-active' : '' }">
<a href.bind="row.href" if.bind="!row.settings.nav">${ row.title }</a>
<a href.bind="row.href" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"
if.bind="row.settings.nav">
${row.title}
<span class="caret"></span>
</a>
<ul if.bind="row.settings.nav" class="dropdown-menu">
<li repeat.for="menu of row.settings.nav">
<a href.bind="menu.href">${menu.title}</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
${userName}
</template>
Here is the typescript file behind it:
import { autoinject, bindable, bindingMode } from "aurelia-framework";
import { Router } from 'aurelia-router'
import { AuthService } from '../../auth/auth-service'
#autoinject
export class Navmenu {
public userName: string = 'anonymous';
private userRole = localStorage.getItem("user_role");
constructor(public authService: AuthService, public router: Router) {
this.userName = authService.getUserName();
}
get routes() {
return this.router.navigation.filter(r => r.settings.roles.indexOf(this.userRole) > -1);
}
}
I wanted to separate the left menu items with the right menu items so there are two sections. This is the right side where you have the user name and the option to logout. The display of the user name is done as a list item in the unordered list tag but before repeat for the right menu items.

Angular2 typescript set selected dropdown button value on page load

Ref : trying to use Dropdown component https://github.com/valor-software/ng2-bootstrap/tree/development/components/dropdown
I can pull the drop down values on clicking button and persist on selection using Typescript but couldn't set the selected value on page load like we do using select option like :
<option [selected]="value.id == value.statusId">
Parent template :
<dropdownst [values]="releaseNames" [selectedReleaseId]="item.releaseId"></dropdownst>
Object : releaseName.ts
export class ReleaseName {
releaseId: number;
name: string;
}
Dropdown Component :
#Component({
selector: 'dropdownst',
template: `<div (click)="$event.preventDefault()">
<div>
<button type="button" class="btn btn-warning btn-sm" (click)="dropdownMenu($event)">
RELEASE (Toggle)
</button>
</div>
<div class="btn-group" dropdown [(isOpen)]="status.isopen">
<button id="dropdown-list" class="btn btn-default" dropdownToggle >
{{title}}
<span class="caret"></span>
</button>
<ul class="dropdown-menu scrollable-menu" role="menu" aria-labelledby="dropdown-list">
<li role="menuitem" *ngFor="let data of values">
<a class="dropdown-item" [id]="data.releaseId" #val [title]="data.name"
(click)="updatePbiRelease(val.id, val.title)" >
{{data.name}}
</a>
</li>
</ul>
</div>
</div> `,
directives: [ DropdownDirective, DropdownMenuDirective, DropdownToggleDirective, CORE_DIRECTIVES],
styles:['.scrollable-menu {height: auto;max-height: 200px;overflow-x: hidden;}']
})
export class Angular2Dropdown implements OnInit{
#Input()
selectedReleaseId: number;
#Input()
values: ReleaseName[];
#Input()
title: string;
private disabledMenu:boolean = false;
appComponent: AppComponent;
private status:{isopen:boolean} = {isopen: false};
constructor(#Inject(forwardRef(() => AppComponent)) private _parent:AppComponent){
this.appComponent = _parent;
}
updatePbiRelease(releaseValue, title){
this.appComponent.updatePbiRelease(releaseValue);
this.title = title;
}
private dropdownMenu($event:MouseEvent):void {
$event.preventDefault();
$event.stopPropagation();
this.status.isopen = !this.status.isopen;
}
ngOnInit() {
}
}
Html Template :
<div (click)="$event.preventDefault()">
<div>
<button type="button" class="btn btn-warning btn-sm" (click)="dropdownMenu($event)">
RELEASE (Toggle)
</button>
</div>
<div class="btn-group" dropdown [(isOpen)]="status.isopen">
<button id="dropdown-list" class="btn btn-default" dropdownToggle >
//Trying to set dropdown selected value here on page load as title from DB on TS Angular 2
{{title}}
<span class="caret"></span>
</button>
<ul class="dropdown-menu scrollable-menu" role="menu" aria-labelledby="dropdown-list">
//Iterate through releaseName has values passed from parent template
//to get name (i.e title) matchng releaseId and Id from DB(i.e item.releaseId)
<li role="menuitem" *ngFor="let data of values">
<a class="dropdown-item" [id]="data.releaseId" #val [title]="data.releaseId == selectedReleaseId ? data.name : data.name"
(click)="updatePbiRelease(val.id, val.title)" >
{{data.name}}
</a>
</li>
</ul>
</div>
Any help would be great.
Did the following changes to Template and ngOnInit() to work
Template :
template: `<div (click)="$event.preventDefault()">
<div>
<button type="button" class="btn btn-warning btn-sm" (click)="dropdownMenu($event)">
RELEASE (Toggle)
</button>
</div>
<div class="btn-group" dropdown [(isOpen)]="status.isopen">
<button id="dropdown-list" class="btn btn-default" dropdownToggle >
{{title}}
<span class="caret"></span>
</button>
<ul class="dropdown-menu scrollable-menu" role="menu" aria-labelledby="dropdown-list">
<li role="menuitem" *ngFor="let data of values">
<a class="dropdown-item" [id]="data.releaseId" #val [title]="data.name"
(click)="updatePbiRelease(val.id, val.title)" >
{{data.name}}
</a>
</li>
</ul>
</div>
</div> `,
Added a if condition on releaseName on parent template
<dropdown *ngIf="releaseNames" [values]="releaseNames" [selectedReleaseId]="item.releaseId">
Set the title value on page load onInit using the id passed from parent template selectedReleaseId
ngOnInit() {
for (var x = 0; x < this.values.length; x++) {
if(this.values[x].releaseId == this.selectedReleaseId) {
this.title = this.values[x].name;
}
}
}

How do I conditionally add a class in aurelia template

I am looking at a way to add a class dynamically to aurelia template. I have to add an active class if the particular li is visible.
Example
<section id="jobsCategoryContainer" class="jobsCategoryContainer">
<h1>{{title}}</h1>
<div *ngFor = "#slide of jobCategorySlides; #i = index" id="job-category-slide_{{i}}" class="job-category-slide" [ngClass]="{active: initialCarouselIndex == i}">
<ul *ngFor = "#item of slide">
<li class="jobDetails" *ngFor="#job of item; #i = index">
<div>
<span id="{{job.name}}" class="jobName">{{ job.name }}</span>
</div>
<div>
<span>{{job.noOfJobs}}</span>
</div>
</li>
</ul>
</div>
<div>
Previous
Next
</div>
</section>
I want to add the active class on below code
<div class="phs-widget-body">
<div class="phs-carousel-inner">
<ul repeat.for = "slide of nearByJobSlides" class="phs-item phs-grid-row" >
<li repeat.for = "item of slide" class="phs-small-6">
<a href="javascript:void(0)">
<div class="phs-job-title">${item.title}</div>
<div class="phs-job-info">
<span class="phs-job-loacation">${item.location}</span>
<span class="phs-job-category">${item.category}</span>
</div>
</a>
</li>
</ul>
</div>
</div>
<div class="phs-widget-footer">
<a class="left" href="#phsNearbyJobs" role="button" data-slide="prev">
<i class="fa fa-angle-left"></i> Move to Previous
</a>
<ol class="phs-carousel-indicators">
<li repeat.for = "slide of nearByJobSlides" data-target="#phsNearbyJobs" data-slide-to="${$index}" class="" click.trigger="changeActiveClass()"></li>
</ol>
<a class="right" href="#phsNearbyJobs" role="button" data-slide="next">
Move to Next <i class="fa fa-angle-right"></i>
</a>
</div>
As well how do I pass an event Object on aurelia?
Just use interpolation
<div class="${ applyMyClass ? 'my-class' : '' }">
E.g.
<div class="${ carouselIndex == $index ? 'active' : '' }">
You don't need to do this with a click event, it's the same as ng2 (only less code!)

How can i set menu to top of the page after scrolling down 500 px

I use bootstrap ver 3.
When I'm scrolling down, I want my menu bar set to top of the page.
screenshot:
My start page when loading show my logo in center & my menu bar in bottom of logo.
Height of page 500px
my menu cod:
<div class="navbar-inverse navbar-default navbar-static-top" role="navigation" > <!-- منو بالا -->
<div class="container my-menubar">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active">صفحه اصلی</li>
<li>محصولات</li>
<li>درباره ما</li>
<li class="dropdown "> خدمات <span class="caret"></span>
<ul class="dropdown-menu my-menubar" role="menu">
<li>خدمات 1</li>
<li>خدمات 2</li>
<li>خدمات 3</li>
<li class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li>Separated link</li>
<li>One more separated link</li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /container -->
</div>
please watch below link :
http://chuckagency.com/wordpress-new/
i want create like this.
Add two attributes below class
.navbar-static-top {
top: 0px;
position: fixed;
}
You can use some javascript like the below to add a class to your menu once you have scrolled down enough.
var listval = $('.section-nav-bar-menu')[0].offsetTop;
$(document).scroll(function() {
var topval = $(document).scrollTop();
if(topval >= listval){
$('.section-nav-bar-menu').addClass('fixed');
} else {
$('.section-nav-bar-menu').removeClass('fixed');
}
});
});
Then you can use CSS to fix the menu bar to the top of the page using the "fixed" class.
There are probably many different implementation of this code, so look around and see what works best for you...
$(window).scroll(function () {
if ($(window).scrollTop() >= 450) {
if ($('.navbar-default').hasClass('navbar-static-top')){
$('.navbar-default').removeClass('navbar-static-top');
$('.navbar-default').addClass('navbar-fixed-top');
}
}
else {
if ($('.navbar-default').hasClass('navbar-fixed-top')){
$('.navbar-default').addClass('navbar-static-top');
$('.navbar-default').removeClass('navbar-fixed-top');
}
}
});