dukt/follow 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dukt/follow

Composer 安装命令:

composer require dukt/follow

包简介

Follow plugin for Craft CMS

README 文档

README

A simple plugin to connect to Follow's API.

Installation

  1. Download the latest release of the plugin
  2. Drop the follow plugin folder to craft/plugins
  3. Install Follow from the control panel in Settings > Plugins

Templating

Following

Users that you are following.

{% if not currentUser %}
    <p>You need to <a href="{{url('follow/login')}}">login</a> in order to see the users you follow.</p>
{% else %}
    {% set users = craft.follow.getFollowing() %}

    {% if users|length > 0 %}

        <p>You are following {{users|length}} users.</p>

        <div class="row">
            {% for user in users %}
                <div class="col-md-4">
                    {% include 'follow/_user' with { user: user } %}
                </div>
            {% endfor %}
        </div>

    {% else %}
        <p>{{ "You are not following anyone."|t }}</p>
    {% endif %}

{% endif %}

Followers

Users that are following you.

{% if not currentUser %}
    <p>{{ 'You need to <a href="{url}">login</a> in order to see you followers.'|t({ url: url('follow/login') })|raw }}</p>
{% else %}
    {% set users = craft.follow.getFollowers(currentUser.id) %}

    {% if users %}

        <p>{{ "You have {count} followers."|t({ count: users|length }) }}</p>

        <div class="row">
            {% for user in users %}
                <div class="col-md-4">
                    {% include 'follow/_user' with { user: user } %}
                </div>
            {% endfor %}
        </div>

    {% else %}
        <p>{{ "No one is following you." }}</p>
    {% endif %}
{% endif %}

Activity

Recent entries from users you are following.

{% if not currentUser %}
    <p>{{ 'You need to <a href="{url}">login</a> in order to see the activity of users you follow.'|t({ url: url('follow/login') })|raw }}</p>
{% else %}
    {% set followingUsers = craft.follow.getFollowing( user.id ) %}

    {% set followingUserIds = [] %}
    {% for followingUser in followingUsers %}
        {% set followingUserIds = followingUserIds|merge([ followingUser.id ]) %}
    {% endfor %}

    {% if followingUserIds|length > 0 %}

        {% set entries = craft.entries.authorId(followingUserIds).find() %}

        {% if entries|length %}
            {% for entry in entries %}
                <div class="media">
                    <div class="media-left text-center">

                        {% if entry.author.photoUrl %}
                            {% set photoUrl = entry.author.photoUrl(80) %}
                        {% else %}
                            {% set photoUrl = resourceUrl('images/user.gif') %}
                        {% endif %}

                        <img src="{{ photoUrl }}" width="80" class="img-circle" />

                        <p>{{ entry.author.fullName }}</p>

                    </div>

                    <div class="media-body">

                        <h4 class="media-heading">{{ entry.title }}</h4>

                        <p>
                            <small>{{ entry.postDate.nice }}</small>
                        </p>

                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Officia, unde molestias odit mollitia sint. Similique, nesciunt, sunt, magnam enim asperiores totam consequuntur ratione nemo quam ut vitae accusantium blanditiis esse.</p>

                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Officia, unde molestias odit mollitia sint. Similique, nesciunt, sunt, magnam enim asperiores totam consequuntur ratione nemo quam ut vitae accusantium blanditiis esse.</p>

                    </div>
                </div>

                <hr>
            {% endfor %}
        {% else %}
            <p>{{ "Start following some users to see their recent entries."|t }}</p>
        {% endif %}
    {% else %}
        <p>{{ "Start following some users to see their recent entries."|t }}</p>
    {% endif %}

{% endif %}

user.html

{% set followers = craft.follow.getFollowers(user.id) %}

<div class="row">
    <div class="col-md-12">

        <div class="panel panel-default">
            <div class="panel-body">

                <div class="row">
                    <div class="col-sm-4">
                        {% if user.photoUrl %}
                            {% set photoUrl = user.photoUrl %}
                        {% else %}
                            {% set photoUrl = resourceUrl('images/user.gif') %}
                        {% endif %}

                        <img src="{{ photoUrl }}" width="90" class="img-circle" />
                    </div>
                    <div class="col-sm-8">

                        <h5>{{ user.fullName }}</h5>

                        {% set followersCount = followers|length %}

                        {% if followersCount > 1 %}
                            <p>{{ "{count} followers"|t({ count: followersCount }) }}</p>
                        {% else %}
                            <p>{{ "{count} follower"|t({ count: followersCount }) }}</p>
                        {% endif %}

                        {% if currentUser and currentUser.id != user.id %}
                            {% if craft.follow.isFollow(user.id) %}
                                <a class="btn btn-default btn-sm" href="{{actionUrl('follow/stopFollowing', {id:user.id})}}">{{ "Unfollow"|t }}</a>
                            {% else %}
                                <a class="btn btn-default btn-sm btn-primary" href="{{actionUrl('follow/startFollowing', {id:user.id})}}">{{ "Follow"|t }}</a>
                            {% endif %}
                        {% else %}
                            <div class="btn btn-default btn-sm btn-primary disabled">{{ "Follow"|t }}</div>
                        {% endif %}

                    </div>
                </div>
            </div>
        </div>

    </div>
</div>

API

FollowVariable

  • isFollow($elementId)
  • getFollowers($userId = null)
  • getFollowing($userId = null)

dukt/follow 适用场景与选型建议

dukt/follow 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 14, 最近一次更新时间为 2017 年 09 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 dukt/follow 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 dukt/follow 我们能提供哪些服务?
定制开发 / 二次开发

基于 dukt/follow 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 14
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 14
  • Watchers: 4
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2017-09-29