Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Related Pages Plugin with image

Started by Muut Archive 10 years ago · 1 replies · 460 views
10 years ago

Hi, I modified the Related Pages Plugin to display an image of the related posts.

An example can be seen here: http://posits.skn1.com/android-aplicaciones-sin-google-play

In user/themes/antimatter/templates/partials I created the file relatedpages.html.twig with this code:
--- html
{% for related_path, score in related_pages %}
{% set related = grav['pages'].get(related_path) %}
{% if related %}
{% if config.plugins.relatedpages.show_score %}
<span class="score">{{ score }}</span>
{% endif %}
<div class="relacionados">
<figure class="bannerrelacionados">
{% set bannerrelated = related.media.images|first %}
<a href="{{ related.url }}" title="{{ related.title }}">{{ bannerrelated.cropZoom(150,150).html }}</a>
</figure>
<p class="titulorelacionados"><a href="{{ related.url }}" title="{{ related.title }}">{{ related.title }}</a></p>
</div>
{% endif %}
{% endfor %}

TXT

And then I customized the style custom.css to leave it as is.

Greetings (sorry for my English, I speak Spanish).
👍 1

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1359 9 years ago
Archive · by Muut Archive, 9 years ago
2 936 9 years ago
Archive · by Muut Archive, 9 years ago
2 4066 9 years ago
Archive · by Muut Archive, 9 years ago
1 2957 9 years ago
Archive · by Muut Archive, 9 years ago
3 1121 9 years ago