Difference between #1 and #2 of
Widget Personalizado

Revision #2 has been created by Cálcio on Dec 2, 2014, 1:57:31 PM with the memo:

Widget Personalizado
« previous (#1)

Changes

Title unchanged

Widget Personalizado

Category unchanged

Tutorials

Yii version unchanged

Tags unchanged

Widgtes, CDataProvider

Content changed

Nesse wikitutorial vou tentar exemplificar de forma mais clara e objetiva o uso de widget com o CDataProvider.  
------
 
Here I will explain with the clear way and objective an use the widget with CDataProvider.


### Controller
[...]
Nesse controller eu fiz um simples select com 2 condições, ordenando de forma crescente e trazendo 10 registros. Isso seria equivalente a:
------
 
On the controller I wrote a simple query with two conditions and got 10 register.
 


```php
[...]
Em **$dataProvider = new CActiveDataProvider('Model',...** o termo **Model** é o nome correspondente ao seu model.
------
 
In **$dataProvider = new CActiveDataProvider('Model',...** the term **Model** It's your model.
 
 
É muito importante observar que **$dataProvider->setPagination(false);** é obrigatório para que ele respeite o limit da consulta, ou seja, sem ele o limit não funciona.  
------
 
It's very important to notice that **$dataProvider->setPagination(false);** is required. It's controls the "Limit" query, In the other words, without "Limit" it's do not work.


### View index
[...]
```

No Lugar desejado da sua view, basta chamar seu widget, seja dentro de um **div**, **span**, **tabela** etc.
 
------
 
Use the code above in your view. Call it on a **div**, **span**, **table** etc.
#### View parcial / partial view No exemplo vou chama-la de arquivoDaView.php ------
 
I used the arquivoDaView.php to call it.


```php
[...]
```

Aqui est
rou criando as tags **<li>** e nelas criando link para uma view qualquer passando como parâmetro _param1 = valor1_ e o texto a ser exibido será o valor contido em _$data->campo2_.
 
Trocando em miudos, eu teria essa linha gerada no
------
 
Here I created a **<li>** tag and I created a link in any view pass as a parameter _param1 = value1_ the text that will be shown is _$data->campo2_.
 
 
 
Trocando em miudos, eu teria essa linha gerada no HTML:
 
------
 
Simply put, I would have this line generated in
HTML:
[...]
Então, para cada item achado na sua consulta ele retornaria um **<li>**
------
 
So, for each item found in his query he would return a **<li>**
6 0
4 followers
Viewed: 10 563 times
Version: 1.1
Category: Tutorials
Written by: Cálcio
Last updated by: Cálcio
Created on: Apr 20, 2012
Last updated: 9 years ago
Update Article

Revisions

View all history