CakePHP 和 Lightview JQuery 插件:增量视图计数

CakePHP and Lightview JQuery Plugin: Increment View Count

本文关键字:视图 Lightview JQuery 插件 CakePHP      更新时间:2023-09-26

我在我的网页中使用以下插件:

http://www.nickstakenburg.com/projects/lightview/

该脚本在显示照片和它应该执行的其他所有操作方面效果很好,但是,我想完成以下我无法完成的任务:

Have the plugin increment view count everytime an image is displayed

我已经在我的photo.php模型中创建了以下操作,但是我想不出使用该插件调用的方法:

function incrementViewCount($id) {
    $this->updateAll(
        array('Photo.viewed' => 'Photo.viewed+1'),                    
        array('Photo.id' => $id)
    );
}

我在我的网站上按照以下内容进行了设置:

<?php
    foreach ($photocategory['Photo'] as $photo){
?>
<li>
<a 
        href="/img/uploads/photos/<?php echo photo['photocategory_id']."/".$photo['image']; ?>" 
        class="lightview" 
        data-lightview-group="shared_options"
    >
    <img 
            style="width:155px;height:113px;" 
            src="/img/uploads/photos/<?php echo $photo['photocategory_id']."/thumb/".$photo['image']; ?>" 
            alt="" 
    />
</a>
</li>
<?php } ?>

如果有人对此插件或jQuery有所了解,并且如果您可以建议一种方法来实现此目的,那就太好了!

如果你正在使用 CakePHP 这个https://github.com/sliker/CakePHP-Counter-Plugin 可能会有所帮助。

具有用于递增计数器的简单调用方法。