Cakephp 3 paginator template with Bootsrap problem with sort() - twitter-bootstrap-3

Currently using paginator sort link inside a bootstrap list like this :
<ul id="myTab" class="nav nav-tabs nav-stacked">
<li class="list-group-item list-group-item-info">Filtrer les résultats de recherche pour les tweets.</li>
<li><?= $this->Paginator->sort('created','<span class="glyphicon glyphicon-time"></span> Les plus anciens',['escape' => false,'direction' => 'asc', 'lock' => true]);?></li>
<li><?= $this->Paginator->sort('created','<span class="glyphicon glyphicon-time"></span> Les plus récents',['escape' => false,'direction' => 'desc', 'lock' => true]);?></li>
<li><?= $this->Paginator->sort('nb_partage','<span class="glyphicon glyphicon-share"></span> Les plus partagés',['escape' => false,'direction' => 'desc', 'lock' => true]);?></li>
<li><?= $this->Paginator->sort('nb_like','<span class="glyphicon glyphicon-heart"></span> Les plus likés',['escape' => false,'direction' => 'desc', 'lock' => true]);?></li>
<li><?= $this->Paginator->sort('nb_commentaire','<span class="glyphicon glyphicon-comment"></span> Les plus commentés',['escape' => false,'direction' => 'desc', 'lock' => true]);?></li>
</ul>
I'm also using a paginator template like this
<?php
return [
'sort' => '<a class="list-group-item" href="{{url}}">{{text}}</a>',
];
?>
When I click on a link, it correctly displays the page and the clicked link changes class thanks to bootstrap,but not for the first two links that change classes both, all the other links work perfectly.
This is because they both sort on 'created'.
Is it possible to differentiate them so that when we click on the first or second, it changes the class not the other, as for other links.

Related

Yii 1.1.21 : is it possible to create two dropdown buttons in the same button group?

I am new to Yii, and I have been LOOKING for documentation on Yii and CMenu. I have used Phalcon and various other frameworks with similar options, but Yii's menu engine is new to me.
I am trying to create a button menu with two drop down menu buttons, each with sub menu items, like this:
Drop Down Button Group
But what is being rendered by the Yii CMenu engine is two drop down menus overlayed on each other and both are being triggered by the same buttons. Like this:
enter image description here
Looking at the rendered code, it looks like the two dropdown menus are being assigned the "dropdown-menu" class by CMenu, (or whatever the bootstrap enabled lib is) and becasue they are in the same button group, when the "open" class is assigned, it's opening BOTH dropdowns at the same time.
So my question is simple, is is even possible, using the CMenu menu arrays, to have two dropdowns in the same. Is there a menu "Item Option" or "HTML Option" I can add to the menu item properties that will all this to reference two different css tags? I know I gotta be missing something.
Here is how the menu's are being built in the view.
$this->menu = array_merge($this->menu, array(
array(
'label' => '<span class="hidden-xs hidden-sm">' . Yii::t('app', 'Export') . '</span>',
'encodeLabel' => false,
'htmlOptions' => array('id' => 'export-or-email-btn', 'class' => 'navbar-btn btn-sm',),
'items' => array(
array(
'label' => Yii::t('app', 'Export'),
'icon' => 'fa fa-file-excel-o',
'visible' => true,
'itemOptions' => array('class' => 'work-order-export-btn'),
),
array(
'label' => Yii::t('app', 'Email Export'),
'icon' => 'fa fa-envelope-o',
'visible' => true,
'itemOptions' => array('id' => $model->getClassName(), 'class' => 'email-export-btn', 'data-grid-id' => 'work-order-grid'),
),
array(
'label' => Yii::t('app', 'Export as Import Template'),
'icon' => 'fa fa-file-excel-o fa-lg',
'visible' => true,
'itemOptions' => array('class' => 'work-order-export-import-btn'),
),),),);
$this->menu = array_merge($this->menu, array(
array(
'label' => '<span class="hidden-xs hidden-sm">' . Yii::t('app', 'Actions') . '</span>',
'encodeLabel' => false,
'htmlOptions' => array(
'id' => 'work-order-actions-btn work-order-actions',
'class' => 'navbar-btn btn-sm',
'style' => 'margin: 0 0 0 15px;',
),
'items' => array(
array(
'icon' => 'fa fa-print fa-lg',
'label' => Yii::t('app', 'Print to PDF'),
'visible' => true,
'itemOptions' => array(
'class' => 'work-order-print-pdf',
),),
array(
'icon' => 'fa fa-print fa-lg',
'label' => Yii::t('app', 'Print'),
'visible' => true,
'itemOptions' => array(
'class' => 'work-order-print-selected',
),),))));
and here is the rendered code snippet:
<div class="btn-toolbar">
<div class="operations btn-group-sm btn-group open">
<button id="export-or-email-btn" class="navbar-btn btn-sm btn btn-primary dropdown-toggle" data-toggle="dropdown" name="yt7" type="button">
<span class="hidden-xs hidden-sm">Export</span>
<span class="caret"></span>
</button>
<ul id="yw6" class="dropdown-menu">
<li class="work-order-export-btn nav-header" data-ol-has-click-handler="">
<i class="fa fa-file-excel-o"></i> Export
</li>
<li id="WorkOrder" class="email-export-btn nav-header" data-grid-id="work-order-grid" data-ol-has-click-handler="">
<i class="fa fa-envelope-o"></i> Email Export
</li>
<li class="work-order-export-import-btn nav-header" data-ol-has-click-handler="">
<i class="fa fa-file-excel-o fa-lg"></i> Export as Import Template
</li>
</ul>
<button id="work-order-actions-btn work-order-actions" class="navbar-btn btn-sm btn btn-primary dropdown-toggle" style="margin: 0 0 0 15px;" data-toggle="dropdown" name="yt8" type="button">
<span class="hidden-xs hidden-sm">Actions</span>
<span class="caret"></span>
</button>
<ul id="yw7" class="dropdown-menu">
<li class="work-order-print-pdf nav-header">
<i class="fa fa-print fa-lg"></i> Print PDF
</li>
<li class="work-order-print-selected nav-header">
<i class="fa fa-print fa-lg"></i> Print Selected
</li>
</ul>
</div>
</div>
I think your problem is you are merging both arrays in the same $this->menu attribute.
Maybe you should use CMenu as widget like in the documentation
$this->widget('zii.widgets.CMenu', array(
'items'=>array(
// Important: you need to specify url as 'controller/action',
// not just as 'controller' even if default action is used.
array('label'=>'Home', 'url'=>array('site/index')),
// 'Products' menu item will be selected no matter which tag parameter value is since it's not specified.
array('label'=>'Products', 'url'=>array('product/index'), 'items'=>array(
array('label'=>'New Arrivals', 'url'=>array('product/new', 'tag'=>'new')),
array('label'=>'Most Popular', 'url'=>array('product/index', 'tag'=>'popular')),
)),
array('label'=>'Login', 'url'=>array('site/login'), 'visible'=>Yii::app()->user->isGuest),
),
));
For more information and attributes check out the official documentation here.

CHtml submit button is not working when 'enter' key press in Yii

In my Yii web application, CHtml submit button is not working when 'enter' key press in Login form. My login form is,
<?php echo CHtml::beginForm(); ?>
<h3 class="form-title">Login to your account</h3>
<div class="alert alert-danger display-hide">
<button class="close" data-close="alert"></button>
<span> Enter any username and password. </span>
</div>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Username</label>
<div class="input-icon">
<i class="fa fa-user"></i>
<?php echo CHtml::activeTextField($model, 'username', array("class" => "form-control placeholder-no-fix", 'placeholder' => "Username")) ?>
</div>
</div>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Password</label>
<div class="input-icon">
<i class="fa fa-lock"></i>
<?php echo CHtml::activePasswordField($model, 'password', array("class" => "form-control placeholder-no-fix", 'placeholder' => "Password")) ?>
</div>
</div><br>
<div class="form-group">
<?php echo CHtml::submitButton(UserModule::t("Login "), array('class' => 'btn green pull-right')); ?>
</div>
<div class="text-danger"><?php echo CHtml::errorSummary($model); ?></div>
<?php echo CHtml::endForm(); ?><br><br><br>
<?php
$form = new CForm(array(
'elements' => array(
'username' => array(
'type' => 'text',
'maxlength' => 32,
),
'password' => array(
'type' => 'password',
'maxlength' => 32,
),
'rememberMe' => array(
'type' => 'checkbox',
)
),
'buttons' => array(
'login' => array(
'type' => 'submit',
'label' => 'Login',
),
),
), $model);
?>
In this login form using chtml submit button. I want to submit this login form by press enter key.
How to resolve this problem.
Please help me.
If you want to use onclick:
<?php echo CHtml::submitbutton(UserModule::t("Login "), array('class ' => 'btn green pull-right', 'onclick' => ' '));?>

reset password does not work with mailgun configuration

I configured laravel 5.1 according to mail docs. Sending mail works fine.
Next step was to add the reset password according to resetting passwords docs. Here I struggle to send the link to the reset-password formular.
Seems like the function to send the reset mail is not triggered. I checked as well with the config/mail.php configuration pretend = true;. There was no entry in the logfile, that a email was send.
Somehow its as well hard to debug, as I could not find the function where the reset email is triggered.
How do I send the reset password with mailgun?
Where is the function locate to send the reset password, or where can I overwrite it, to test it?
This are my configurations:
.env
# ...
MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mail.org
MAIL_PORT=587
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAILGUN_DOMAIN=mg.foo.com
MAILGUN_SECRET=key-foobar.etc
# ....
config/service.php
//...
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
],
//...
config/mail.php
// ...
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => 'foo#test.com', 'name' => 'foo'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'pretend' => false,
// ...
app/Http/routes.php
// ...
Route::group([
'prefix' => LaravelLocalization::setLocale(),
'middleware' => [ 'localeSessionRedirect', 'localizationRedirect' ]
], function() {
//Route::controllers([ 'password' => 'Auth\PasswordController', ]);
// works only if the user is logged out!!!1
// Password reset link request routes...
Route::get('password/email', 'Auth\PasswordController#getEmail');
Route::post('password/email', 'Auth\PasswordController#postEmail');
// Password reset routes...
Route::get('password/reset/{token}', 'Auth\PasswordController#getReset');
Route::post('password/reset', 'Auth\PasswordController#postReset');
});
//...
resources/views/auth/password.blade.php
#extends('layout')
#section('content')
<div class="container">
<form method="POST" action="/password/email">
{!! csrf_field() !!}
#if (count($errors) > 0)
<ul>
#foreach ($errors->all() as $error)
<li>{{ $error }}</li>
#endforeach
</ul>
#endif
<div class="row">
<div class="col-md-6">
{!! Form::label('email', trans( 'mes.email' )) !!}
<input type="email" name="email" value="{{ old('email') }}" class="form-control">
</div>
<div class="col-md-8">
<button type="submit" class="btn">
Send Password Reset Link
</button>
</div>
<div>
</form>
</div>
#endsection
Incorrect routes was the problem. The example from the docs did hardcode the action value in the form element.
This did not reflect my routes configuration. With the following changes the password reset email works:
app/Http/routes
// change route to a named route
// Route::post('password/email', 'Auth\PasswordController#postEmail');
Route::post('password/email', ['as' => 'password.email', 'uses' => 'Auth\PasswordController#postEmail']);
resources/views/auth/password.blade.php
<!-- Use the named route in the form builder and remove csrf_field -->
{!! Form::open(['route' => 'password.email']) !!}

CDetailView don't show properly Chtml::link's HTML data

i use Chtml::link in one CDetailView.
array(
'label'=>'Images',
'type'=>'html',
'value'=> CHtml::link('<i class="fa fa-tag"></i>','#',array('data-target'=>'#myModal','class'=>'tag','data-toggle'=>'modal')),
),
But html properly not generated. it only add few property like below
<a class="tag" href="#"><i class="fa fa-tag"></i></a>
How can i add all property?
array(
'label'=>'Images',
'type'=>'html',
'value'=> CHtml::link('<i class="fa fa-tag"></i>','#',array('data-target'=>'#myModal','class'=>'tag','data-toggle'=>'modal')),
),
change 'type'=>'html', to
'type'=>'raw',
After changing the code its look like below block
array (
'label' => 'Images',
'type' => 'raw',
'value' => CHtml::link('<i class="fa fa-tag"></i>','#',array('data-target'=>'#myModal','class'=>'tag','data-toggle'=>'modal')),
),

Pipe character causes "unexpected token" error in Html.BeginForm

I am trying to recreate the HTML design of an existing login form for use in an MVC4 program. Most of this is fine, however when I try to enter a pipe character ( | ) between two elements, it throws an error "unexpected token". You can see it there at the bottom, after the button and before the anchor. Any ideas why this is an error? Is there a way to fix it? (Other than removing the pipe character?)
#using (Html.BeginForm("Login", "AccountController", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { #class = "form-login form-wrapper form-narrow" }))
{
#Html.AntiForgeryToken()
#Html.ValidationSummary(true)
<h3 class="title-divider"><span>Login</span> <small>Not signed up? #Html.ActionLink("Sign Up Here.", "Register")</small></h3>
#Html.LabelFor(m => m.UserName)
#Html.TextBoxFor(m => m.UserName, new { #class = "input-block-level" } )
#Html.ValidationMessageFor(m => m.UserName)
#Html.LabelFor(m => m.Password)
#Html.PasswordFor(m => m.Password, new { #class = "input-block-level" })
#Html.ValidationMessageFor(m => m.Password)
#Html.LabelFor(m => m.RememberMe, new { #class = "checkbox" })
#Html.CheckBoxFor(m => m.RememberMe)
<button class="btn btn-primary" type="submit" value="Log in" >Sign in</button>
| Forgotten Password?
}
Put it inside <text> tags or use the #: operator
<text>|</text>
or
#:|
Inside the using statement, you are actually in a razor code block, so anything not inside an html tag or preceded by the #: operator will be read as server code.