Yii2 pagination listview PAGE params - yii2

is there any way to hide PAGE param in Yii2 pagination listview?
current is domain/(anyattribute)?page=2
output should be domain/(anyattribute)/2

I don't think you can hide it. If you want to hide all of your param attributes then it is possible.
Pjax::begin(['enablePushState' => false]);
//your grid
Pjax::end();

Take a look on https://yii2-cookbook.readthedocs.io/pagination-pretty-urls/
It should solve your problem.

Related

Yii2 submit form and return the result in Pjax container

How to submit the form, process the data, send it to action and in the end, place it in the pjax container? I know solution where the pjax container is wrapping the form but my case is something like this:
$form = ActiveForm::begin();
...
...
...
ActiveForm::end();
some html
Pjax::begin(['id' => 'container']);
The result from the controller action goes here
Pjax::end():
I've seen solution like this with javascript/jQuery function along ago but can't find it now. Can some give me example or at least some useful link. Thank you in advance! P.s. Red a lot of articles but couldn't fine something for my case.

Kartik Gridview conflict with my templates menu

I have a template that i was using for my project.
Look at the picture below:
This is when i am not using the kartikGrid. the dropdown menu running as well as the template want.
look at the image below:
this is when i use kartik, the dropdown menu not running anymore.
can some body tell me why it happen.
The template using different bootsrap version with kartik.
thaks.
Hope some body help me.
Imaginaroom, that did the trick for me thank you.
My top menu wasn't responding (direct link, or drop down menu) after kartik was used. I added an id to my menu widget and it did the trick.
echo Nav::widget([
'id' => 'topMenuID',
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => $menuItems,
]);
Manually assign different ids to all widgets, so there won't be any conflicts.
If you don't assign ids to widgets, yii gives them one automatically, but the problem occures when loading data with ajax or pjax, then Yii cannot know which ids are already used in the page.
Every widget in Yii2 has a property 'id' that you can assign in configuration array when calling a widget.
Add this code in layout or page that has problem:
$this->registerJs( "$(document).ready(function() { $('.dropdown-toggle').dropdown(); });", View::POS_END, 'ecommerceProductJs' );

formHelper type time : avoiding the annoying dropdown select input?

When i use the cakePHP form helper for a type 'time' field, it automatically generates a dropdown select input and not an easy&easy html5 type time keyboard input like this
Anyone has a quick solution to this ? (preferably without any javascript)
thanks !
FYI, finally i used a jQuery timepicker, that's working fine ! find it here
And after importing the css and js through cakePHP, it's very easy to use.
For example:
With an form element like this (note the type => text)
echo $this->Form->input('time', array(
'type'=>'text',
'label'=>'RĂ©el',
'div'=> array(
'class'=>'two columns')
));
you just call it with
<script>
$('#TimeID').timepicker();
</script>
Just lock the type by manually adding it.
So if you want to use a text field for JS snippets:
echo $this->Form->input('time', array('type' => 'text'));
You can also make it anything else (manually).
For "time" you can try
echo $this->Form->input('time', array('type' => 'time'));
Don't forget to adjust your data form input if necessary.
But careful with HTML5 stuff. This is not suitable for all browsers and therefore can lead to problems in some.

CakePHP hidden _method POST

When using the FormHelper->create(...), the HTML that gets rendered looks like this:
<form action="/blogs/add" method="post" accept-charset="utf-8">
<div style="display:none;">
<input type="hidden" name="_method" value="POST">
</div>
<!-- omitted: form inputs -->
</form>
Why is that div with the display:none; style there? How do I make it not show up?
UPDATE: Just to be clear, I'm wondering why both the div AND the hidden input inside the div show up. They don't seem to be necessary, and therefore I don't want them to be there.
For anyone coming to this recently, there is a simple solution to this now that doesn't involve a custom helper. Using the FormHelper templates, the block of code in question is generated by the 'hiddenBlock' template. (See the full list of default templates here: https://api.cakephp.org/3.2/class-Cake.View.Helper.FormHelper.html#%24_defaultConfig).
So, to amend the example given in CakePHP's documentation to match this case and remove the wrapping <div> around the hidden <input> for _method (assuming HTML5):
// In your View class
$this->loadHelper( 'Form' , [ 'templates' => 'app_form' ] );
// in config/app_form.php
return [
'hiddenBlock' => '{{ content }}'
];
I was confronted with this problem because I recently implemented a Content Security Policy that doesn't allow inline styling, and I thought I should share my working solution.
The div is there to be valid HTML.
Non-block-level elements (such as <input>) are not valid directly inside <form> tags until HTML5. Source
Edit: To answer your question, you can't easily get rid of it. It's hard-coded into FormHelper::create(), you'd have to override that method in a custom helper. Why is it bothering you anyways?
This link might help you.
Whenever you use FormHelper->create() method ,A hidden input field is generated to override the default HTTP method. You can also change it by passing type option. Kindly ask if it not worked for you.
Try:
echo $this->Form->create('User', array(
'inputDefaults' => array(
'div' => false
)
));
The divs won't be created on any input of the form.
use hiddenField => false property

Cakephp Link is not recognized in HTML

I generate in Cakephp with Html->link a link
echo $this->Html->link('Download',array(
'plugin'=> 'galleries',
'controller'=> 'galleries',
'action'=> 'download',
$download),array('class'=>'down'));
The output is
Download
This link is not recognized. I can not click on it.
But if I put the output link and implement it in the HTML code, all is fine
After this I tried to echo the link - same problem.
This is a snippet from my view
<nav>next<?php if($download){ echo $this->Html->link('Download',array('plugin' => 'galleries', 'controller' => 'galleries','action' => 'download', $download),array('class'=>'down')); } ?>prev</nav>
Maybe somebody can give me a little hint?
Solution:
It was not a PHP Problem but CSS Problem... specially a z-index Problem in my Jquery Plugin (ImageViewer) rolleyes
The schemata of the HTML is:
<article><div class="info"><nav></nav</div></article><article><div class="info"><nav></nav</div></article><article><div class="info"><nav></nav</div></article>
The Problem were the nav tags in every article tag. The "prev&next" links appear in every nav structure but not the "download" link. ergo: i can click on the "prev&next" links but not on the "download" link... So, for a fast solution i set the z-index for my current article view. But i must rework my HTML Code structure
Thanks for reading my question.