ajax pagination in cakephp , can't know how to use it - cakephp

how to use ajax pagination in cakephp .I'm also using search the database by the keywords also.. data only matches with keyword shoud be displayed in pagination
how to use ajax pagination in cakephp .I'm also using search the database by the keywords also.. data only matches with keyword shoud be displayed in pagination

Have You tried it .. refer the book , ajax pagination example also there, and in paginator add condition option ... ie. `
$this->paginate=array((`array('condition'=>model.field )like=>%key%),limit=>10) ;

Related

AFC Repeater and wp-rest api in React.js

Need to render ACF repeater in react. I am able to display ACF text Fields but not repeater fields. Need to find out if anyone has an example of how to map through a repeater field.
Repeater field group Is called Skills.
Im also new in this stuff, but I will try to help you.
So, the first thing that you need is to download and install ACF to REST API plugin so you can use ACF with Wordpress API. I assume, that you already have it, because as you said before - you can display text fields.
Once you can send data through Wordpress API, you need to preview of JSON sent by Wordpress (in this case), so you can display necessary data. Mine is called React Developer Tools and I installed it as Chrome extension.
Link to Chrome store
It should look like this:
As you can see, my component is called Home.js, yours may be called differently. Chose component that is fetching all the data that you need.
Now, you just need to use your repeater. It would be much easier if you showed us your code. I don't really know what kind of data you are calling through api, so I guess these are pages.
{ pages[0].acf.technologie_lista.map ( (field, index) => (
<div key={index} className="single-field">
{ field.nazwa_technologii }
</div>
) ) }
Let's break it down.
1 - My project contains two pages. I have chosen the first one, because only this one has needed ACF fields. technologie_lista is acf field name.
2 - You need to use map function to list all posts. You need to assign key to each element.
nazwa_technologii is just a repeater sub field name.
And that's all. I might make some rookie mistakes, but it work's for me. I hope that i helped. Cheers!

Set focus on autocomplete field

I have a form that has some fields.
One field is autocomplete
.
The field is filled with information from a table
$f->addField('autocomplete','idfield','Field')->setValueList( $this->api->db->dsql()
->table('items')->field('id,name')->do_getAssoc() );
I'm trying to set the focus on that field when the page loads.
I have did this
On top of the page
$p->js()->_load('seteo_foco');
And then
seteo_foco.js
$(function(){
$("select:first").focus();
})
But this does not work.
Anybody can help ?
Thanks
Try TRUE like
$this->js(true)->_load('seteo_foco'); to load js file.
But in your js code your selector is incorrect. You need to specify you unique field. I'd use something like $form->getElement('field_name')->js(true)->focus(); on the page after the form has been initialized.

Cakephp Pagination URL

I am facing a problem in cake php pagination. In my project I have Category Suppose 'Wooden' , In this I have Sub Category as 'Wooden Tables' and further 'Wooden tables' has many products. In sub category i am doing pagination . I am showing 10 items per page. Now the problem is that When i click on any of the pagination link , its missing sub category number. for example : the URL should look like this : http://amazingtech.in/lariya/products/index/4/page:2 but when i click on pagination link the URL look like this http://amazingtech.in/lariya/products/index/page:2 . It is missing the sub category number 4 , which leads to page not found error. and when i manually enter the URL Like this . It works.
I don't know how to modify pagination URL. Thanks in advance.
Pagination - that is selecting or sorting results - isn't the same as searching for them by criteria, even though Cake supports passing them as an array or named params. That is to say, conditions of your find() are not preserved in the same way as your pagination params.
So You'd need to include your condition as a named or query parameter: eg: assuming your category is 'category' (it might be category_id, replace as needed)
http://amazingtech.in/lariya/products/index/category:1234/page:2
Or possibly:
http://amazingtech.in/lariya/products/index/category:Wooden/page:2 //more SEO friendly
Or even:
http://amazingtech.in/lariya/products/index/4/page:2
http://amazingtech.in/lariya/products/index/Wooden/page:2 //more SEO friendly
To do it this last way you'll need to setup your controller to look for the first URL param in and assign it as a condition of your find() operation:
public function index($category = null) {
$conditions = array('Products.category_id' => $category);
...etc
}
MORE: CakePHP Cookbook Parameters
That way, when you paginate - as long as you're going through the same controller - can preserve that category.

Angular UI bootstrap: Type ahead select multiple

I am using angular UI bootstrap type-ahead directive for type-ahead in a form
http://angular-ui.github.io/bootstrap/
I am fetching the records from remote server via $http service. It is working fine.
However I can select only one element from list at a time.
I want to select multiple values from the list and show all currently selected element in input field with a remove button just like tags for SO. The selected tags are stored in angular array model.
How to achieve this ?
I have read documentation for Angular UI bootstrap but I am not able to find anything.
This guy made a directive for this. Should do exactly what you want and it's even using the ui-bootstraps typeahead.
https://github.com/mbenford/ngTagsInput
The best solution I have found so far is io.select
it does exactly what you require, multi-select typeahead.
and the markup is neat and clean too e.g:
<oi-select
oi-options="list.id as list.description for list in lists"
ng-model="tags"
multiple
placeholder="Select">
</oi-select>
This component is also compatible with bootstrap and the new bootstrap 4.
In js file :
To list all selected items, use $item with typeahead-on-select and push to an array for ex.evtMem. delete fn to delete selected item.
HTML :
Use table to list all array values using ng-repeat. Addition to that add remove glyphicon image and function to delete corresponding item.

Cakephp 2.0 Pagination with dropdown

I am doing pagination in cakephp. By default there is a list in
"$this->Paginator->numbers" but i want some changes in pagination design so i want all pages in dropdwon and current page is selected in dropdown. I successfully get the dropdown by writing the following code but the problem is that when i click on the page it wil not change
thanks in advance
`
< select>
echo $this->Paginator->numbers(array('tag'=>'option'));
</select>
`
You have to bind event onChange to your select element with JS. It should redirect you to selected page. You can see how to construct jump url in cake's documentation. You can also use this solution but notice it was written for cake 1.x and will need some changes.

Resources