2017 © Pedro Peláez
 

craft-plugin craft-like

image

dukt/craft-like

  • Wednesday, August 30, 2017
  • by benjamindavid
  • Repository
  • 3 Watchers
  • 35 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 5 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

Like for Craft CMS

A simple plugin to connect to Like's API., (*1)


Installation

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

Templating

Like button

{% 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 %}

List likes for an element

{% 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 %}

Your Likes

Entries and asset that you like., (*2)

Entries:, (*3)

{% 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 %}

Assets:, (*4)

{% 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)

The Versions

30/08 2017

0.9.7

0.9.7.0

  Sources   Download

30/08 2017

0.9.0

0.9.0.0

  Sources   Download

30/08 2017

0.9.1

0.9.1.0

  Sources   Download

30/08 2017

0.9.6

0.9.6.0

  Sources   Download

30/08 2017

dev-dev/0.9

dev-dev/0.9

  Sources   Download

30/08 2017

dev-feature/notifications

dev-feature/notifications

  Sources   Download

03/06 2016

dev-master

9999999-dev

Like plugin for Craft CMS

  Sources   Download

The Requires

 

03/06 2016

dev-dev/1.0

dev-dev/1.0

Like plugin for Craft CMS

  Sources   Download

The Requires

 

03/06 2016

1.0.0

1.0.0.0

Like plugin for Craft CMS

  Sources   Download

The Requires