收藏
[模仿]

收藏

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

根据官方点赞插件修改的的收藏插件。

read.htm 页面使用钩子

钩子【1】 read_plugin_body.htm

自制模板添加

<span class="text-center mx-1">
    <!-- id="thread-collection" tid="<?php echo $thread['tid'];?>" 必须保留 -->
    <a id="thread-collection" data-uid="<?php echo $uid;?>" class="h5" rel="nofollow" tid="<?php echo $thread['tid'];?>" href="javascript:void(0);">
        <!-- <i class="icon-thumbs-o-up"></i> 未点收藏可换成自己的图片 -->
        <i class="icon-star-o"></i>
    </a>
    <!-- id="thread-collections" 必须保留 -->
    <span id="thread-collections" class="ml-1 small">
        <?php echo format_number($thread['hfdr_collections']);?>
    </span>
</span>

 

钩子【2】read_js.htm

自制模板添加

<script>
    var uid = '<?php echo $uid;?>';
    var tid = '<?php echo $tid;?>';
    /* <i class="icon-fa-star"></i> 已点收藏可换成自己的图片 */
    var collectiond = '<i class="icon-star"></i>';
    /* <i class="icon-icon-star-o"></i> 未点收藏可换成自己的图片 */
    var uncollectiond = '<i class="icon-star-o"></i>';
    if ('0' != uid) {
        $.xpost(xn.url('my-collection'), {'type': 2, 'tid':tid}, function (code, data) {
            if (0 == code) $('#thread-collection').html(collectiond);
        });
    }
    var body = $('body');
    body.on('click', 'a#thread-collection', function () {
        let jthis = $(this);
        let uid = jthis.attr('data-uid');
        if ('0' != uid) {
            var tid = jthis.attr('tid');
            $.xpost(xn.url('my-collection'), {'type': 0, 'tid': tid}, function (code, message) {
                var threadcollections = $('#thread-collections');
                var collections = xn.intval(threadcollections.html());
                if (0 == code) {
                    $('#thread-collection').html(collectiond);
                    threadcollections.html(collections + 1);
                } else if (1 == code) {
                    $('#thread-collection').html(uncollectiond);
                    threadcollections.html(collections - 1);
                } else {
                    $.alert(message);
                }
            });
        } else {
            $.ajax_modal(xn.url('user-login'), 'Login', 'md');
        }
        return false;
    });
</script>

 

user.htm 页面使用钩子 user_common_count_register_before.htm

自行制作模板添加代码

<span class="mx-1">
    <span class="mr-1">
        <?php echo lang('hfdr_collection_get');?>
    </span>
    <!-- 得到收藏 -->
    <?php echo $_user['well_get_collections'];?>
</span>
0
最新回复(0)
开发者作品