More excerpts

This commit is contained in:
Oliver Davies 2015-06-18 08:58:56 +01:00
parent 262b5dca2f
commit 867d8efef2
25 changed files with 167 additions and 3 deletions

View file

@ -8,6 +8,13 @@ tags:
- drupal-planet
- drupal
---
{% block excerpt %}
Today, I had a situation where I was displaying a list of teasers for news article nodes. The article content type had several different fields assigned to it, including main and thumbnail images. In this case, I wanted to have different output and fields displayed when a teaser was displayed compared to when a complete node was displayed.
I have previously seen it done this way by adding this into in a node.tpl.php file:
{% endblock %}
{% block content %}
Today, I had a situation where I was displaying a list of teasers for news article nodes. The article content type had several different fields assigned to it, including main and thumbnail images. In this case, I wanted to have different output and fields displayed when a teaser was displayed compared to when a complete node was displayed.
I have previously seen it done this way by adding this into in a node.tpl.php file:
@ -63,3 +70,4 @@ array (
~~~~
Now, within my theme I can create a new node--article-teaser.tpl.php template file and this will get called instead of the node--article.tpl.php when a teaser is loaded. As I'm not specifying the node type specifically and using the dynamic <em>$node->type</em> value within my suggestion, this will also apply for all other content types on my site and not just news articles.
{% endblock %}