Take the 2-minute tour ×
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It's 100% free, no registration required.

I'm creating a tumblr-esque blog with a bunch of different entry types.

One of the entry types will be named "Image". When I'm on the entry page for an "Image" entry, I'd like to be able to show 10 more entries with the same "Image" entry type.

Is this possible?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

You can get the entry’s current type handle via entry.type, and craft.entries supports a type param for finding entries of a given type, so you can plug those two together:

{% set otherEntries = craft.entries.section('blog').type(entry.type) %}
share|improve this answer

Yes. This is certainly possible.

I'm not sure how you're templating / naming is setup but you can get entries by entry type and you can check an entry's type. To get entries by a specific type:

craft.entries.section('blog').find({type: 'imagePost', limit: 10})

Here's some helpful references for craft.entries: Entries Cheat Sheet - Craft Docs For the Entry Model

You could structure some kind of comparison, to see if the current entry is a specific type, and if it is query and render the desired additional entries.

{% if entry.type == 'imagePost' %}
  {% for post in craft.entries.section('blog').find({type: 'imagePost'}) %}
...
{% if entry.type == 'textPost' %}
  {% for post in craft.entries.section('blog').find({type: 'textPost'}) %}
...

However there are many ways to do what you want depending on your setup. Please note I used the name imagePost instead of image, to avoid any confusion there might be with a common name like image. I'm not sure if that could cause name conflicts or if it's a reserved keyword / field etc.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.