Comments (18)
Hi @Pablossoo and thank you for your interest in this module!
You need a mysql database (not tested in other databases). Table should have a primary key (PK). And model for this table, for example Post.
In module settings you can to set like this:
'models' => [
123 => \common\models\Post::className()
],
where key 123 - id for link model in module auxiliary tables, value - path to class name definition (this needs for reduce table size - we stored only integer key).
If you have problems with integration module, feel free to ask any questions!
from yii2-vote.
Ok, let me explain my problem more precisely.
My entity model
class Adresssite extends \yii\db\ActiveRecord
{
public static function tableName()
{
return 'adresssite';
}
public function rules()
{
return [
[['adress'], 'string', 'max' => 255],
[['adress'], 'unique'],
];
}
public function attributeLabels()
{
return [
'id_adress' => 'Id Adress',
'adress' => 'Adress',
];
}
}
Now if I set all config like as tutorial, but I use a basic app yii2- it's any problem?
'bootstrap' => ['log',
'chiliec\vote\components\VoteBootstrap',
],
'vote' => [
'class' => 'chiliec\vote\Module',
// show messages in popover
'popOverEnabled' => true,
// global values for all models
// 'allowGuests' => true,
// 'allowChangeVote' => true,
'models' => [
// example declaration of models
// app\models\Adresssite::className(), if unncoment gets Uncaught Error: Class 'app\models\Adresssite' not found in...
// 'backend\models\Post',
// 2 => 'frontend\models\Story',
// 3 => [
// 'modelName' => \backend\models\Mail::className(),
// you can rewrite global values for specific model
// 'allowGuests' => false,
// 'allowChangeVote' => false,
// ],
],
],
in next step I put widget to view
echo \chiliec\vote\widgets\Vote::widget([
'model' => $data,
// optional fields
// 'showAggregateRating' => true,
]);
but if I try click voteup or vote down I get error
SyntaxError: expected expression, got ','
What is differance beetwen model agregate and agreagate_rating?
from yii2-vote.
I use a basic app yii2- it's any problem?
It's not a problem. I think your model not in app\models\
. Before class declaration you watch line like namespace app\models;
?
but if I try click voteup or vote down I get error
SyntaxError: expected expression, got ','
uncomment this line too:
What is differance beetwen model agregate and agreagate_rating?
aggregate contains all votes, aggregate_rating contains only aggregate data for every id (this needs for improving performance).
from yii2-vote.
Still not working but...
I can;t use app\models\Adresssite::className(), only class, now i doesn't get an error (class not found). My entity has namespace app\models.
But still show error SyntaxError: expected expression, got ','
my new config
'vote' => [
'class' => 'chiliec\vote\Module',
// show messages in popover
'popOverEnabled' => true,
// global values for all models
// 'allowGuests' => true,
// 'allowChangeVote' => true,
'models' => [
app\models\Adresssite::class,
],
],
Ok I think find error. In console at onclick function
onclick="vote(0, , 'like');
onclick="vote(0, , 'dislike');
How it fix?
from yii2-vote.
::class
not the same to ::className()
. Hmm, try to change config like this:
'models' => [
['modelName' => 'app\models\Adresssite'],
],
from yii2-vote.
Ok, it's resolve this problem. Now what is second problem with onclick?
from yii2-vote.
Are you sure that your model have Primary key? Because you didn't have target id (which is primaryKey()[0]
)
from yii2-vote.
Ya, he has PK, look
https://gyazo.com/4f50997666b667bf2c4710dacdc43694
from yii2-vote.
var_dump($this->primaryKey());
Can you exec this code in model and write result here?
from yii2-vote.
Ya, I created new method with this code and I called in view.
$model->myAction();
result;
array(1) { [0]=> string(9) "id_adress" }
from yii2-vote.
Fine! Now try exec:
var_dump($this::className());
from yii2-vote.
string(21) "app\models\Adresssite"
from yii2-vote.
Great! In module config written this string?
from yii2-vote.
'modules' => [
'vote' => [
'class' => 'chiliec\vote\Module',
// show messages in popover
'popOverEnabled' => true,
'allowGuests' => true,
'allowChangeVote' => true,
'models' => [
['modelName' => 'app\models\Adresssite'],
],
],
....
]
className() still not working.
from yii2-vote.
Very strange, it should work :(
Is your project located in somewhere in open source?
from yii2-vote.
OK.
so it's application;
https://github.com/Pablossoo/basic
Controller it siteController , action actionShowCommentSite($id) (she render view)
view/site/site.php
config you have in config folder.
if you want I can sent my database sql file and maybe you try reproduce my issue.
from yii2-vote.
Sure, put your sql file in this repository.
from yii2-vote.
Closed because no response for a long time.
from yii2-vote.
Related Issues (20)
- Суммарный рейтинг
- Получение расшифрованного IP
- Надписи на иконках голосования HOT 1
- если вместо id например news_id как запускать? HOT 1
- обновился теперь с news_id показывает все но HOT 8
- Интеграция с готовыми визуальными компонентами HOT 1
- Обновить модель после голосования HOT 19
- Asset для виджета HOT 5
- Избранное HOT 3
- Свой вид в виджете HOT 2
- Много запросов + сортировка HOT 23
- Trying to get property of non-object
- Trigger event после успешного голосования HOT 4
- Suggetion : Use Bootstrap Popover Plugin to display messages HOT 14
- Question on determining if user voted already. HOT 1
- Возможность переопределения моделей HOT 1
- Пропадает пробел HOT 2
- Bug: Class m160209_074651_add_indexes_for_aggregate_rating_table does not exist HOT 3
- Ошибка в логике голосования... HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yii2-vote.