undefinedfix
Sign in

Yii reading volume

DavidLyonsGarcia edited in Thu, 02 Dec 2021

When Yii framework increased the number of reading articles today, it found that the number of reading increased by 2 per visit

It turns out that whenever I render templates and layouts in the controller, the controller is executed twice.

Later, I found that as long as I set the layout to false or there is no HTML code in the layout, the controller will execute once, and if there is HTML code in a single layout, the controller will execute twice immediately. Once again, we found that the amount of reading on the top of the endpage increased by 1, once on the bottom of the endpage, the amount of reading will increase by 2

Please ask, does anyone encounter this problem, how to solve it, thank you

2 Replies
user620543
commented on Fri, 03 Dec 2021

图片描述

If you find that there can't be any empty elements such as "a" or "a class", just remove the poster or add a poster to the poster

kcomf
commented on Fri, 03 Dec 2021

If you add it to the controller, it should not have this problem. If you use js to call a special link to add it, it should not have this problem. Just don't do it in the view view.

lock This question has been locked and the reply function has been disabled.