dukt/like

此包最新版本(1.0.1)无可用许可信息。

Craft CMS 的 Like 插件

维护者

详细信息

github.com/dukt/like

源代码

安装: 20

依赖: 0

建议者: 0

安全: 0

星标: 44

关注者: 5

分支: 8

类型:craft-plugin

1.0.1 2017-09-28 23:24 UTC

This package is auto-updated.

Last update: 2024-08-29 04:37:39 UTC


README

一个简单的插件,用于连接到 Like 的 API。

安装

  1. 下载该插件的最新版本
  2. like 插件文件夹放入 craft/plugins
  3. Settings > Plugins 控制面板安装 Like

模板

Like 按钮

{% if currentUser %}
    {% if craft.like.isLike(element.id) %}
        <a class="btn btn-default" href="{{actionUrl('like/remove', {id:element.id})}}"><span class="glyphicon glyphicon-star"></span> Unlike</a>
    {% else %}
        <a class="btn btn-primary" href="{{actionUrl('like/add', {id:element.id})}}"><span class="glyphicon glyphicon-star"></span> Like</a>
    {% endif %}
{% else %}
    <a class="btn disabled btn-primary" href="#">Like</a>
{% endif %}

列出元素的点赞

{% set likes = craft.like.getLikes(element.id) %}

{% if likes|length > 0 %}

    {% for like in likes %}
        <a href="#">
            {% if like.user.photoUrl %}
                <img src="{{like.user.photoUrl}}" width="34" class="img-rounded" data-toggle="tooltip" data-original-title="{{like.user.email}}" />
            {% else %}
                <img src="http://placehold.it/34x34" data-toggle="tooltip" class="img-rounded" data-original-title="{{like.user.email}}">
            {% endif %}
        </a>
    {% endfor %}

{% endif %}

你的点赞

你点赞的条目和资产。

条目

{% set entries = craft.like.getUserLikes('Entry') %}

{% if entries %}
    <ul>
        {% for entry in entries %}
            <li>{{entry.title}}</li>
        {% endfor %}
    </ul>
{% else %}
    <p>You haven't liked any entry yet.</p>
{% endif %}

资产

{% set assets = craft.like.getUserLikes('Asset') %}

{% if assets %}
    <div class="row">
        {% for asset in assets %}
            <div class="col-md-4">
                <img class="thumbnail img-responsive" src="{{asset.url({width:200, height: 140})}}" />
            </div>
        {% endfor %}
    </div>
{% else %}
    <p>You haven't liked any asset yet.</p>
{% endif %}

API

LikeVariable

  • isLike($elementId)
  • getLikes($elementId = null)
  • getUserLikes($elementType = null, $userId = null)