How to customize Navbar property in Yii2 - css

I have navigation header like this:
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-collapse collapse">
<form class="navbar-form navbar-right" role="search">
<div class="form-group has-feedback">
<input id="searchbox" type="text" placeholder="Search" class="form-control">
<span id="searchicon" class="fa fa-search form-control-feedback"></span>
</div>
</form>
</div><!--/.navbar-collapse -->
</div>
</div>
I have problem when I want to convert this code using yii\bootstrap\NavBar;:
<div class="navbar-collapse collapse">
<form class="navbar-form navbar-right" role="search">
<div class="form-group has-feedback">
<input id="searchbox" type="text" placeholder="Search" class="form-control">
<span id="searchicon" class="fa fa-search form-control-feedback"></span>
</div>
</form>
</div><!--/.navbar-collapse -->
And this is the code of my Layout using yii\bootstrap\NavBar;:
<?php
NavBar::begin([
'brandLabel' => 'My Company',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar navbar-inverse navbar-fixed-top',
'role' => 'navigation',
],
]);
NavBar::end();
?>
I have been read Navbar Widget, but still don't understand. Is there anyone who can teach me to using Navbar widget on Yii2 framework?.

Ok here is the code for that,here i am just placing the searchbox from exactly what you posted in question and i am guessing that you know how to echo other menu links in navbar
Anyway it goes like this
<?php
NavBar::begin([
'brandLabel' => 'My Company',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar navbar-inverse navbar-fixed-top',
'role' => 'navigation',
],
]);
$menuItems = [
['label' => 'Home', 'url' => ['controller url here']],
];
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => $menuItems,
]);
echo "<form class='navbar-form navbar-right' role='search'>
<div class='form-group has-feedback'>
<input id='searchbox' type='text' placeholder='Search' class='form-control'>
<span id='searchicon' class='fa fa-search form-control-feedback'></span>
</div>
</form>";
NavBar::end();
?>

Related

Why doesn't bootstrap 4.0 split my div container into two columns

Woordpres. I create content-article.php like this:
<div class="container">
<div class="row">
<div class="col-lg-8">
<div class="sk-post-item">
<?php
the_content();
?>
<?php
comments_template();
?>
</div>
</div>
<div class="col-lg-4">
lorem
</div>
</div>
</div>
Component comments_template() It looks like this:
<div class="sk-comments-form">
<?php
function reorder_textarea_comment_field( $fields ) {
$comment_field = $fields['comment'];
$cookies_field = $fields['cookies'];
unset( $fields['comment'] );
unset( $fields['cookies'] );
$fields['comment'] = $comment_field;
$fields['cookies'] = $cookies_field;
return $fields;
}
add_filter( 'comment_form_fields', 'reorder_textarea_comment_field' );
?>
<div>
<?php
if(comments_open()){
comment_form(
array(
'title_reply' => '',
"comment_field" => '<div class="form-group col"><div class="pb-2"><label for="comment">Twój komentarz</label><textarea id="comment" class="form-control sk-comments-form-control mb-md-3 m-sm-0" name="comment" rows="4"></textarea>',
"class_form" => "< bg-light rounded-3 shadow p-4 p-lg-5 mt-4 >",
'submit_button'=> '<button class="btn-primary btn-lg text-white sk-comment-form-btn">' ,
'comment_notes_before' => '',
"label_submit" => __( "Wyślij komentarz" ),
"id_submit" => ( "comment-submit" ),
"class_submit" => ( "btn-primary btn-lg text-white sk-comment-form-btn" ),
"submit_button" => '<br><input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />',
'fields' => array(
'author' => '<div class="row form-group col md-6 ml-md-1"><div class="col-md-6" ><label for="comment">Imię i nazwisko</label><input id="author" class="form-control sk-comments-form-control" name="author" ></div>',
'email' => '<div class="col-md-6 form-group col md-6"><label for="comment">Twój email</label><input id="email" class="form-control sk-comments-form-control" name="email" ></div>',
),
),
);
}
?>
In this way .col-lg-8 i .col-lg-4 they are arranged one above the other, not next to each other.
How will I remove .sk-comments-form with comments_template() it's good.
What's wrong there?

Wordpress Bootstrap Navwalker Driving Me Bonkers

Having trouble getting the navwalker to expand on mobile.
I have added the code to functions php
// Register Custom Bootstrap Navigation Walker
require_once get_template_directory() . '/wp-bootstrap-navwalker.php';
Here is my navwalker code, if anyone can help me resolve this conundrum I would be most greatful. Please excuse the formatting on here.
<nav class="main-menu navbar navbar-bg thetop" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!-- navbar-brand is hidden on larger screens, but visible when the menu is collapsed -->
<a class="navbar-brand" href="<?php echo home_url(); ?>">
<?php if (function_exists('the_custom_logo')) {
the_custom_logo();
}
else{
bloginfo('name');
}
?>
</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<ul class="nav navbar-nav">
<?php
wp_nav_menu( array(
'theme_location' => 'primary',
'depth' => 2,
'container' => 'div',
'container_class' => 'collapse navbar-collapse',
'container_id' => 'bs-example-navbar-collapse-1',
'menu_class' => 'nav navbar-nav',
'fallback_cb' => 'WP_Bootstrap_Navwalker::fallback',
'walker' => new WP_Bootstrap_Navwalker())
);
?>
</ul>
<!-- Search Form -->
<form id="searchform" class="navbar-form navbar-right" role="form" action="<?php echo home_url( '/' ); ?>">
<div class="input-group">
<input type="text" class="form-control" name="s" placeholder="Ara"><span class="input-group-btn"><button type="submit" class="btn btn-default btn-primary -red"><span class="glyphicon glyphicon-search"></span></button></span>
</div>
</form>
</div>
</nav>
Nevermind I figured this out. I am building a new theme using wpBootstrapStarter. Recently updated the theme which also updated bootstrap release using jquery 3.3.2. I just downgraded and all is well.
I guess the devs didn't fully test before release. Good job i spotted via console.

Woocommerce - How to change the html markup of checkout fields on the checkout page?

I use this hook:
add_action( 'woocommerce_after_checkout_billing_form', 'add_custom_field' );
function add_custom_field( $checkout ) {
echo '<div id="custom_field_wrapper">';
woocommerce_form_field( 'custom_field', array(
'type' => 'text',
'class' => array('custom_field_class'),
'label' => __('Custom Field'),
'placeholder' => __('Please input value ...'),
'required' => false, ),
$checkout->get_value( 'custom_field' ) );
echo '</div>';
}
and i get this markup:
<div id="custom_field_wrapper">
<p class="form-row custom_field_class" id="custom_field_field" data-priority="">
<label for="custom_field" class="">Custom Field</label>
<input type="text" class="input-text " name="custom_field" id="custom_field" placeholder="Please input value ..." value="">
</p>
</div>
But the required markup looks like this:
<div class="row order-form__row">
<div class="col-lg-3 col-md-4">
<label class="label" for="index-field">Индекс:</label>
</div>
<div class="col-lg-6 col-md-6">
<input class="input" type="text" name="index" id="index-field"/>
</div>
<div class="col-lg-3 col-md-2"><a class="field-after" href="javascript:void(0);" target="_blank">Забыли индекс?</a></div>
</div>
Kind smart people help solve the dilemma ... How to change the html markup according to the requirements?

bootstrap cakephp help needed

i am creating a form with cakephp2 and bootstrap everything is working fine but im stuck in little confusion and i cant fix this kindly any bootstrap or cake expert help me thanks,
Check this envelop its stretching upwards
here is my code
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<span class="glyphicon glyphicon-envelope"></span>
</span>
<?php echo $this->Form->input('email',
array(
'class' => 'form-control',
'type' => 'email',
'placeholder' => 'Enter Email'
)
); ?>
</div>
<!--<input type="email" class="form-control" id="email" placeholder="Enter email" required="required" /></div>-->
</div>
Pass the argument 'label' => false will prevent to display the label
Use
<?php echo $this->Form->input('email',
array(
'class' => 'form-control',
'type' => 'email',
'placeholder' => 'Enter Email',
'label' => false
)
); ?>
You should use label false in your code.
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<span class="glyphicon glyphicon-envelope"></span>
</span>
<?php echo $this->Form->input('email',
array(
'class' => 'form-control',
'type' => 'email',
'label'=>false,
'placeholder' => 'Enter Email'
)
); ?>
</div>
<!--<input type="email" class="form-control" id="email" placeholder="Enter email" required="required" /></div>-->
</div>

Editing Row using KendoGrid

Hi I am Having a View Where I am using Kendo Grid.I am editing the row of the table but getting the error.Here is my Code goes.
#(Html.Kendo().Grid<Invoice.Models.ViewModels.Setup.AccountViewModel>()
.Name("Account")
.Columns(columns =>
{
columns.Bound(p => p.AccountID).Title("ID").Width(250);
columns.Bound(p => p.AccountType).Title("Account Type").Width(225);
columns.Bound(p => p.AccountName).Title("Account Name").Width(225);
columns.Bound(p => p.Currency).Title("Currency").Width(225);
columns.Bound(p => p.Status).ClientTemplate("#=data.Status#").Width(225).HtmlAttributes(new {style="text-align:center"});
//columns.Command(command => command.Custom("Edit").Click("showDetails")).Title("Action").Width(150);
columns.Command(command => { command.Edit();}).Width(90);
})
.ToolBar(toolbar =>
{
toolbar.Template(#<text>
<div class="row-fluid">
<div class="span1">
<div class="toolbar" style="height:25px;">
<ul id="menu" style="width:38px; margin-left:22px;" class="span6">
<li style="width:36px;">
<i class="fa fa-plus"></i>
<ul>
#foreach (var account in #ViewBag.AccountType)
{
<li style="width:100px;" class="openid">
#if (#account.Value == "Bank")
{
<label id="Bank1">#account.Value</label>
}
#if (#account.Value == "CreditCard")
{
<label id="Credit">#account.Value</label>
}
#if (#account.Value == "Cash")
{
<label id="Cash1">#account.Value</label>
}
</li>
}
</ul>
</li>
</ul>
</div>
</div>
</div>
</text>);
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.HtmlAttributes(new { style = "height:550px;" })
//.Selectable(selectable => selectable
//.Mode(GridSelectionMode.Multiple))
.Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("UpdateAccount"))
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error("error_handler"))
//.ServerOperation(true)
.Model(model => model.Id(p => p.AccountID))
.Read(read => read.Action("Account_Read", "Setup"))
.Create(c => c.Action("Account_Create", "Setup"))
.Update(u => u.Action("Account_Update","Setup"))
)
)
Now the thing is that I am fetching the "Status" from the database that is a HTML tag <span class="label label-success">Active</span> and converting this into the label As Active,InActive and Blocked and Displaying it into the Grid but the problem is that when i am editing this i am getting this error.
"A potentially dangerous Request.Form value was detected from the client (Status="
Here i am using My own template as
UpdateAccount(.Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("UpdateAccount")))
wherein i am not including the Status Field but still getting this error.
My UpdateAccount template is as Follows:
<input type="hidden" name="AccountID" id="AccountID" />
<div class="control-group">
<label class="control-label">Account Type</label>
<div class="controls">
<input type="text" name="AccountType" id="AccountType" />
</div>
</div>
<div class="control-group">
<label class="control-label">Account Name</label>
<div class="controls">
<input type="text" name="AccountName" id="AccountName" />
</div>
</div>
<div class="control-group">
<label class="control-label">Currency</label>
<div class="controls">
<input type="text" name="Currency" id="Currency" />
</div>
</div>
Please help me !!!
You can set a template for just one column like this :
columns.Bound(p => p.AccountType)
.Title("Account Type")
.Width(225)
.Template(#<img src="./Images/accountIco.png" title="#item.AccountName" />#item.AccountType);

Resources