2

My question is closely related to this question: How do I display entries from multiple entry types?

I would like to have two blog post types:

  • Regular blog posts (Title, Body, etc)
  • External links posts (Link out to another site)

I imagined I would display them in the same area, by dates created, like a standard blog, but clicking some of the links would go to external link.

I want to make this as easy as possible for my client, so I would like them to be in the same place if possible, but also open to any other solutions. Has anyone done something like this?

I thought about the possibility of two channels, and combining all posts and ordering by date? Not completely sure how I would go about that though.

2

I think your answer is in the post you referenced. Create two entry types in a single section, each of which contains different fields (and/or some in common). Then loop through all the entries and test for entry type in the output.

{% set entries = craft.entries.section('blog').find() %}

{% for entry in entries %}
    {% if entry.type ==  'linklist' %}
        <h1><a href="{{ entry.externalLink }}">{{ entry.title }}</a></h1>
    {% else %}
        <h1><a href="{{ entry.url }}">{{ entry.title }}</a></h1>
    {% endif %}

    {{entry.body }

{% endfor %}

The user will have to understand how to change the entry type in Craft's UI (it's the dropdown in the right column, but it's pretty clear once they've been shown how to do it once).

|improve this answer|||||
  • BTW, I love Hyperakt's work! – James Muspratt Jan 22 '15 at 1:05
  • I hadn't even seen the entry types! Of course that makes sense, craft makes it too easy. Thanks for the help there, James! And if you're ever in town, stop by Hyperakt! – Nick Jan 22 '15 at 1:13
  • Thanks! And FYI if you have a bunch of entry types it's a little nicer to use switch – James Muspratt Jan 22 '15 at 1:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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