Wordcount demo
This is a demonstration of Yii2-wordcount for the Yii framework 2.0. It counts the words in the fields heading and body in the ActiveRecords from the database table architect.
The database contains texts in Dutch (articles on Amsterdam architects), for which I apologize. However, it's the only table at my disposal with substantial text fields.
Total words in headings: 163
Total words in body: 58507
Showing 21-39 of 39 items.
Name | Heading | Words in heading | Words in body |
---|---|---|---|
Herman Knijtijzer | Bescheiden man van harmonie | 4 | 1566 |
Willem Kromhout | ‘Ik vind dorheid een gruwel’ | 5 | 1474 |
Margaret Kropholler | Een leven lang vrouwvriendelijk bouwen | 5 | 1542 |
Cornelis Kruyswijk | Rechtzinnig buitenbeen van de Amsterdamse School | 6 | 1545 |
Han van Loghem | De rode architect | 3 | 1348 |
Huig Maaskant | ‘Het kleine werk ligt me niet’ | 6 | 1488 |
Ben Merkelbach | 0 | 1595 | |
Cornelis Outshoorn | Meesterwerk vol tegenslag | 3 | 1712 |
Jan Ernst van der Pek | 0 | 1589 | |
Koos Pot-Keegstra | Schoonheid schuilt in eenvoud | 4 | 1433 |
Dirk Roosenburg | Amerikaanse weelde voor het Amsterdamse kantoorvolk | 6 | 1506 |
Theo Sanders | Voorloper van het GVB | 4 | 1516 |
Arthur Staal | Nooit rumoerig of pathetisch | 4 | 1400 |
Daniël Stalpaert | Sober om te imponeren | 4 | 1451 |
Joop van Stigt | 0 | 1516 | |
Jacques van Straaten | Van De Bijenkorf naar de goot | 6 | 1296 |
Philip Warners | Pionier van het etagehuis | 4 | 1483 |
Henrik Wijdeveld | 100 jaar onmogelijke plannen | 3 | 1512 |
Jan Wils | Eenvoudig en strak | 3 | 1552 |
Model code
<?php use sjaakp\wordcount\WordCount; class Architect extends \yii\db\ActiveRecord { public static function tableName() { return 'architect'; } public function behaviors() { return [ [ 'class' => WordCount::class, 'attribute' => [ 'heading' => 'hcount', 'body' => 'bcount' ] ] // ]; } // ... }
View code
<?php use yii\grid\GridView; ?> <?= GridView::widget([ 'dataProvider' => $dataProvider, 'columns' => [ 'nicename', 'heading', 'hcount', 'bcount', ], ]) ?>