Favorites 收藏夹
[原创]

Favorites 收藏夹

分类:功能增强
版本:1.00.08
下载:516
获星:0
创建时间:2021-01-02
最后更新:2022-12-12
免费
请到后台应用商店下载 / Please go to the background app store to download

收藏最喜欢的内容。Favorite content.

 

1.用户不能收藏自己的内容;

2.个人中心收藏夹,查看收藏内容;

3.支持自行删除收藏内容;

4.限制收藏数量1000,达到限制后提示清理后可继续收藏;

2021.12.26 增加用户中心收藏,依赖主程序2.2版本

 

 

read.htm 模板使用钩子,自制模板添加如下代码

【钩子1】read_plugin_body.htm

<span class="text-center mx-1">
    <!-- id="favorites" tid="<?php echo $thread['tid'];?>" 必须保留 -->
    <a id="favorites" class="h5" rel="nofollow" tid="<?php echo $thread['tid'];?>" href="javascript:void(0);" title="<?php echo lang('well_favorites_tips');?>" aria-label="<?php echo lang('well_favorites_tips');?>">
        <!-- <i class="icon-cube"></i> 可替换自己的图标 -->
        <i class="icon-cube"></i>
    </a>
    <!-- id="favorites-n" 收藏次数 -->
    <span id="favorites-n" class="ml-1 small">
        <?php echo format_number($thread['well_favorites']);?>
    </span>
</span>

【钩子2】read_js.htm

<script>
    var uid = '<?php echo $uid;?>';
    var body = $('body');
    body.on('click', 'a#favorites', function () {
        if (uid) {
            var tid = $(this).attr('tid');
            $.xpost(xn.url('home-favorites'), {'type': 0, 'tid':tid}, function (code, message) {
                if (0 == code) {
                    var favorites = $('#favorites-n');
                    favorites.html(xn.intval(favorites.html())   1);
                    $.alert(message);
                } else {
                    $.alert(message);
                }
            });
        } else {
            $.ajax_modal(xn.url('user-login'), 'Login', 'md');
        }
        return false;
    });
</script>

 

自制模板

home_favorites.htm

user_favorites.htm

 

5
最新回复(0)