Need help: Multiple Listing channels with one template. DRY I have several Listing channels that all use the same templates:

E.g.

Templates:


/templates/view/overview.html
/templates/view/detail.html


Channels


News
Research Updates
Upcoming Events


How can I only list the entries for each channel at their respective URL without having to duplicate the templates? 

E.g.

"http://mysite.com/news" should only list the the latest 20 news stories with links to the detail page.

{% for entry in craft.entries.section('news', 'research', 'events').limit(20).find() %}
&lt;div class="col-sm-6"&gt;
    &lt;h2 class="Heading"&gt;&lt;a href="{{ entry.url }}" title="{{ entry.title }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/h2&gt;
    &lt;p class="Date"&gt;{{entry.postDate|date('M j, Y')}}&lt;/p&gt;
    &lt;p&gt;{{ excerpt|length &gt; 250 ? excerpt|slice(0, 200) ~ '...' : excerpt  }}&lt;/p&gt;
    &lt;p&gt;&lt;a href="{{ entry.url }}" title="{{ entry.title }}" class="ReadMore"&gt;Read More&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;                          


{% endfor %}
A good option here is to make use of craft.request. As long as the URL is the section handle, you can do something like this:

{% current_section = craft.request.firstSegment %}

{% for entry in craft.entries.section(current_section).limit(20).find() %}
...
{% endfor %}


If the url is mysite.com/news, firstSegment will return 'news', which you can use in your craft.entries call.

UPDATE:

If your URLs need to be different than the section handles, make use of Twig's include with tag. For each section, you will need an index.html template with the following:

{% set current_section = 'thisSectionHanle' %}
{% include listPage.html with current_section %}


listPage.html can be the template that has the actual fetch and display logic. Using include with, listPage.html will have access to the current_section variable.

So not perfectly dry, but the main logic chunk will not have to be repeated.