A simple plugin to connect to Like's API.
- Download the latest release of the plugin
- Drop the
likeplugin folder tocraft/plugins - Install Like from the control panel in
Settings > Plugins
{% if currentUser %}
{% if craft.like.isLike(element.id) %}
<a class="btn btn-default" href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%7B%7BactionUrl%28%27like%2Fremove%27%2C+%7Bid%3Aelement.id%7D%29%7D%7D"><span class="glyphicon glyphicon-star"></span> Unlike</a>
{% else %}
<a class="btn btn-primary" href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%7B%7BactionUrl%28%27like%2Fadd%27%2C+%7Bid%3Aelement.id%7D%29%7D%7D"><span class="glyphicon glyphicon-star"></span> Like</a>
{% endif %}
{% else %}
<a class="btn disabled btn-primary" href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%23">Like</a>
{% endif %}
{% set likes = craft.like.getLikes(element.id) %}
{% if likes|length > 0 %}
{% for like in likes %}
<a href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%23">
{% if like.user.photoUrl %}
<img src="proxy.php?url=https%3A%2F%2Fgithub.com%2F%7B%7Blike.user.photoUrl%7D%7D" width="34" class="img-rounded" data-toggle="tooltip" data-original-title="{{like.user.email}}" />
{% else %}
<img src="proxy.php?url=http%3A%2F%2Fplacehold.it%2F34x34" data-toggle="tooltip" class="img-rounded" data-original-title="{{like.user.email}}">
{% endif %}
</a>
{% endfor %}
{% endif %}
Entries and asset that you like.
Entries:
{% 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:
{% 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="proxy.php?url=https%3A%2F%2Fgithub.com%2F%7B%7Basset.url%28%7Bwidth%3A200%2C+height%3A+140%7D%29%7D%7D" />
</div>
{% endfor %}
</div>
{% else %}
<p>You haven't liked any asset yet.</p>
{% endif %}
- isLike($elementId)
- getLikes($elementId = null)
- getUserLikes($elementType = null, $userId = null)