Targeting default or selected entry in a collection
  • I have a collection of articles and I'm trying to figure out a more elegant way to either show the latest article for when the user accesses "/articles" or the selected article if a user navigates to "/articles/some-article".

    Below is my current implementation, is there an easier way?

    <v:if param="id">
    <v:template filename="entry" />
    </v:if>
    <v:else>
    <v:collection path="entries" limit="1">
    <v:template filename="entry" />
    </v:collection>
    </v:else>

  • 2 Answers sorted by
  • That's pretty much how you do it. You check for the existence of a variable if it's a permalink page, if not show the first entry in the collection, which can be done with v:section

    <v:section path="entries">
    <v:template filename="entry" />
    </v:section>



    You could also just separate the permalink page into a new page: "/article/some-article"

  • That's basically how I do it as well.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

In this Discussion