TypeError

count(): Argument #1 ($value) must be of type Countable|array, string given

/home/253096.cloudwaysapps.com/kwghpcwvvz/public_html/protected/extensions/widgets/views/WLastArticles.php(21)

09     $index = mb_strpos($content, ' ', $len, 'utf-8');
10     if($index !== false)
11         $content = mb_substr($content, 0, $index, 'utf-8').'...';
12 
13     $url = Yii::app()->createUrl('article',array('id'=>$article->article_id,'title'=>$article->title));
14 
15     echo '<div class="article">
16         <a href="'.$url.'">
17             <h4>'.$article->title.'</h4>
18             <p>
19                 '.$content.'
20             </p>';
21             if(count($article->tag) > 0)
22             {
23                 echo '<div class="tags">';
24                 foreach($article->tag as $tag)
25                     echo '<div class="tag">'.$tag->title.'</div>';
26                 echo '</div>';
27             }
28     echo '
29         </a>
30     </div>';
31 }

Stack Trace

#4
+
 /home/253096.cloudwaysapps.com/kwghpcwvvz/public_html/protected/extensions/widgets/views/WLastArticles.php(21): CActiveRecord->__get()
16         <a href="'.$url.'">
17             <h4>'.$article->title.'</h4>
18             <p>
19                 '.$content.'
20             </p>';
21             if(count($article->tag) > 0)
22             {
23                 echo '<div class="tags">';
24                 foreach($article->tag as $tag)
25                     echo '<div class="tag">'.$tag->title.'</div>';
26                 echo '</div>';
#8
+
 /home/253096.cloudwaysapps.com/kwghpcwvvz/public_html/protected/extensions/widgets/WLastArticles.php(32): CWidget->render()
27     }
28     
29     public function run()
30     {
31         $this->render('WLastArticles',array(
32         ));
33     }
34 }
#10
+
 /home/253096.cloudwaysapps.com/kwghpcwvvz/public_html/protected/views/site/index.php(12): CBaseController->widget()
07         <div class="block">
08             <h2 class="title">Last Articles</h2>
09             <div class="lastArticles">
10             <?php
11                 $this->widget('ext.widgets.WLastArticles', array(
12                     'limit'=>5
13                 ));
14             ?>
15             </div>
16         </div>
17         <a href="<?php echo Yii::app()->baseUrl; ?>/article/" id="allArticles">See All Articles</a>
2024-03-29 05:18:44 Apache/2.4.58 (Debian) Yii Framework/1.1.13